【发布时间】:2018-02-16 20:04:11
【问题描述】:
我可以使用以下代码抓取 Javascript 呈现的页面:
import scrapy
from scrapy_splash import SplashRequest
class QuotejscrawlerSpider(scrapy.Spider):
name = 'quotejscrawler'
def start_requests(self):
yield SplashRequest(
url = 'http://www.horsedeathwatch.com/',
callback=self.parse,
)
def parse(self, response):
for quote in response.xpath("//tr"):
item = {
'horse': quote.xpath('td[@data-th="Horse"]/a/text()').extract(),
'date': quote.xpath('td[@data-th="Date"]/text()').extract(),
'cause': quote.xpath('td[@data-th="Cause of Death"]/text()').extract(),
}
yield item
我想通过点击每个网页上的“下一步”按钮来抓取多个网页。我是新手。 有什么建议吗?
【问题讨论】:
标签: python scrapy scrapy-splash