【发布时间】:2021-10-15 16:30:38
【问题描述】:
我正在编写一个 Google 应用程序脚本,该脚本应该将网页保存为 pdf 文件在我的 google 驱动器内的文件夹中。这是我现在的代码:
function downloadFiles(){
var fileName ="";
var fileSize ="";
var response=UrlFetchApp.fetch("https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal");
var rc=response.getResponseCode()
if(rc==200){
var fileBlob=response.getAs('application/pdf');
var folder= DriveApp.getFolderById("ID")// folder where the files to compare will be stored
if (folder!=null){
var file=folder.createFile(fileBlob)
fileName= file.getName()
fileSize= file.getSize()
}
}
var fileInfo={'rc':rc, "filename":fileName,"filesize":fileSize}
}
由于某种原因,当我运行我的脚本时,我得到了这个错误:
Exception: Conversion from text/html to application/pdf failed.
我在一些网站上读到它可能与限制或类似的东西有关......你知道我该如何解决这个问题吗?
【问题讨论】:
-
存在导致 PDF blob 无法从 HTML 正确转换的错误。谷歌有一个错误的问题跟踪器。通过访问问题跟踪器并单击星号,您可以让 Google 知道这是一个需要修复的问题。请点击以下问题的“星号”:https://issuetracker.google.com/issues/196100674
标签: google-apps-script google-sheets