pyspider爬虫设置延时

来源:互联网 发布:日本化妆品推荐 知乎 编辑:程序博客网 时间:2024/05/18 17:40


pyspider爬虫设置延时,在scrawl中添加function函数,设置时延.

另外可以正则匹配网址方法也可以参见本条方案

def index_page(self, response):

print(response)

for each in response.doc('a[href^="http://www.zhanqi.tv/games/"]').items():

if re.match("http://www.zhanqi.tv/games/\w+", each.attr.href, re.U):

self.crawl(each.attr.href,

fetch_type='js', # fetch_type参数

js_script="""

function() {

setTimeout(window.scrollTo(0,document.body.scrollHeight), 5000);

}

""",callback=self.list_page)


原创粉丝点击