等到网页加载到 Scrapy 中

Wait until the webpage loads in Scrapy

我正在使用 scrapy 脚本加载 URL 使用 "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

URL 似乎至少需要 5 秒才能加载。所以我想让 Scrapy 等待一段时间来加载 item['Description'] 中的整个文本。 我在 settings.py 中尝试了 "DOWNLOAD_DELAY" 但没有用。

简要了解 firebug 或其他工具以捕获 Ajax 请求的响应,这些请求是由 javascript 代码发出的。您可以做出一系列响应来捕获 page.There 上传后出现的那些 ajax 请求是几个相关问题:parse ajax contentretreive final page, parse dynamic content.