【发布时间】:2021-07-30 06:22:56
【问题描述】:
我正在使用以下 Google Sheet Apps 脚本抓取目标价格的排名。
function TRTP(url) {
const html = UrlFetchApp.fetch(url).getContentText();
const res = html.match(/<div class="flexcb_ bgwhite h12 w12 px0 displayflex positionrelative py3">.+?(<text .+?<\/text>)/);
if (!res) throw new Error("Value cannot be retrieved.")
return res;
}
我正在使用以下网址:https://www.tipranks.com/stocks/msft/forecast
这是试图从上面的 URL 的以下快照中提取数据。
Tiprank 的目标价格:
这应该会给我一个很长的 OuterHTML,其中也存在值。我使用 Google Sheet 公式从中提取目标价格。
这适用于 WSJ 等其他网站,但不适用于 Tiprank。
【问题讨论】:
-
仅供参考,它是 scrape(和 scraping、scraped、scraper)不是废品。 “废弃”意味着像垃圾一样扔掉:-(
标签: web-scraping google-sheets