【发布时间】:2021-02-21 23:28:13
【问题描述】:
我对抓取/apify 非常陌生,但我正在尝试做一些简单的事情,当搜索文本框成为焦点时,在 bing.com 上获取“趋势搜索”。
目前,我有:
async function pageFunction(context) {
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm,'');
}
const $ = context.jQuery;
// log an alert when the search box gets focus
$( "#sb_form_q").focus(function() {
context.log.info('focus on the input box');
});
$("#sb_form_q").focus();
// wait for the resulting div to appear
context.waitFor('#sw_as');
context.log.info('div #sw_as appeared');
const myTerm = $("li div.sa_tm").find("span.sa_tm_text").text();
// Return an object with the data extracted from the page.
// It will be stored to the resulting dataset.
return {
myTerm
};
}
正如我所说,我对 apify/actors 比较陌生,因此我将不胜感激。我认为它应该很简单,但它只是没有点击。感谢您的帮助。
【问题讨论】: