0
我正在使用scrapy爲了從網站提取數據。 當我打開json結果文件時,它總是返回空。 我scrapy代碼附:scrapy返回空json文件
from scrapy import Spider
class StackSpider(Spider):
name = "stack"
allowed_domains = ["youtube.com"]
start_urls = ["https://www.youtube.com/results?search_query=Motorcycle+Accident+Stunt+Rider+Knocks+Himself+Out+Stunt+Fail+2015"]
def parse(self,response):
questions = Selector(response).xpath('//a')
for question in questions:
item = StackItem()
item['title'] = question.xpath(
'a/text()').extract()
item['url'] = question.xpath('//@href]').extract()
yield item