当使用jQuery从网站上抓取时,网站需要引用jQuery

时间:2018-04-13 01:35:22

标签: jquery html node.js web-scraping nightmare

我正在编写一个脚本,使用pat = '(?P<want1>.*) - (?P<want2>.*) - (?P<want3>.*)' df.join(df.variable.str.extract(pat, expand=True)) Date variable want1 want2 want3 0 02-01-08 Australia - Sydney - A Australia Sydney A 1 03-01-08 Australia - Sydney - A Australia Sydney A 2 04-01-08 Australia - Sydney - A Australia Sydney A 3 05-01-08 Canada - Toronto - B Canada Toronto B 4 06-01-08 Canada - Toronto - B Canada Toronto B select * from Test where col1=1 and col2 = 2; VALUES (1,1,NULL), --col1=1 is TRUE and col2 = 2 is UNKNOWN (2,NULL,2), --col1=1 is UNKNOWN and col2 = 2 is TRUE (3,1,2) --col1=1 is TRUE and col2 = 2 is TRUE: row returned because both are TRUE select * from table where col1=1 and col2 <> 2 VALUES (1,1,NULL), --col1=1 is TRUE and col2 <> 2 is UNKNOWN (2,NULL,2), --col1=1 is UNKNOWN and col2 <> 2 is FALSE (3,1,2) --col1=1 is TRUE and col2 <> 2 is FALSE 从名为Gumtree(澳大利亚Craigslist)的网站上删除广告列表,我收到错误消息:

  

(node:15902)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:1):错误:$未定义

我想知道网站是否需要这样的参考:

Nightmare.js

让我用jQuery刮掉它。

1 个答案:

答案 0 :(得分:0)

我不熟悉Nightmare.js,但写了一些刮刀,只是在Chrome的控制台中运行。如果网站没有jQuery,您可以使用以下脚本添加它:

var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jq.onload = jq.onreadystatechange = function() {
    if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
        console.log("jQuery loaded");
        jQuery.noConflict();
    };
};