我从 Google Apps 脚本编码开始。
所以我尝试了这个例子:获取(网址) https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app?hl=de#fetch%28String%29
// The code below logs the HTML code of the Google home page.
var response = UrlFetchApp.fetch("http://www.google.com/");
Logger.log(response.getContentText());
我收到的标签来自:
<!doctype html> to <style>
但没有这些标签:
</head>, <body>, </body> or </html>
这是一个不正确的 Google Apps 脚本示例还是我的错误?
如何从 google.com 响应完整的 HTML 代码?
Logger.log 会自动截断特定长度后显示的字符串。您将收到整个页面,但只能看到日志中的第一部分。
// The code below logs the HTML code of the Google home page.
var response = UrlFetchApp.fetch("http://www.google.com/");
var content = response.getContentText();
Logger.log(content);
//log last 1000 chars of content
Logger.log(content.substr(-1000));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)