-2
Scapy1.4
を使用して、一連のURLを指定してWebページからコンテンツをクロールします。ページからさまざまな情報(URL、タイトル、本文など)を抽出する方法についてのヘルプが必要です。Scrapyからウェブページ内のすべてのコンテンツを抽出する方法
現在、私は、次のURL
https://healthlibrary.epnet.com/GetContent.aspx?token=3bb6e77f-7239-4082-81fb-4aeb0064ca19&chunkiid=32905
を使用していますが、私のコードは、そのようなXPath
式を設定し、なぜ私が理解できない
class gsapocSpider(BaseSpider):
name = "gsapoc"
start_urls =["https://healthlibrary.epnet.com/GetContent.aspx?token=3bb6e77f-7239-4082-81fb-4aeb0064ca19&chunkiid=32905"]
def parse(self, response):
responseSelector = Selector(response)
for sel in responseSelector.xpath('//ul/li'):
item = GsapocItem()
item['title'] = sel.xpath('//ul/li/a/text()').extract()
item['link'] = sel.xpath('a/@href').extract()
item['body'] = sel.xpath('//body//p//text()').extract()
#item['text'] = sel.xpath('//text()').extract()
#body = response.xpath('//body//p//text()').extract()
#print(body)
yield item