等待网页加载到Scrapy中 [英] Wait until the webpage loads in Scrapy

查看:105
本文介绍了等待网页加载到Scrapy中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用scrapy脚本使用"yield"加载URL.

I am using scrapy script to load URL using "yield".

MyUrl = "www.example.com"
request = Request(MyUrl, callback=self.mydetail)
yield request
def mydetail(self, response):
    item['Description'] = response.xpath(".//table[@class='list']//text()").extract()
    return item

该网址似乎至少需要5秒钟才能加载.因此,我希望Scrapy等待一段时间以将整个文本加载到item ['Description']中. 我在settings.py中尝试了"DOWNLOAD_DELAY",但没有用.

The URL seems to take minimum 5 seconds to load. So I want Scrapy to wait for some time to load the entire text in item['Description']. I tried "DOWNLOAD_DELAY" in settings.py but no use.

推荐答案

简要介绍一下Firebug或其他工具来捕获对javascript代码所做的Ajax请求的响应.您可以做出一系列响应,以捕获在页面上传后出现的那些ajax请求.有几个相关的问题:重新整理最终页面解析动态内容.

Make a brief view on firebug or another tool to capture responses for Ajax requests, which were made by javascript code. You are able to make a chain of responses to catch those ajax requests which appear after uploading of the page.There are several related questions: parse ajax content, retreive final page, parse dynamic content.

这篇关于等待网页加载到Scrapy中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆