我正在使用VS代码+ git bash将这些数据抓取到JSON中。但是我没有将任何数据转换成JSON或没有任何数据转换成JSON。 JSON文件为空。
import scrapy
class Contactsspider(scrapy.Spider):
name= 'contacts'
start_urls = [
'https://app.cartinsight.io/sellers/all/amazon/'
]
def parse(self,response):
for contacts in response.xpath("//td[@title= 'Show Contact']"):
yield{
'show_contacts_td': contacts.xpath(".//td[@id='show_contacts_td']").extract_first()
}
next_page= response.xpath("//li[@class = 'stores-desc hidden-xs']").extract_first()
if next_page is not None:
next_page_link= response.urljoin(next_page)
yield scrapy.Request(url=next_page_link,callback=self.parse)