在用scrapy genspider创建爬虫文件时,运行代码如下:
scrapy genspider car https://car.autohome.com.cn/price/brand-15.html
在spiders文件夹下的创建了car.py文件,代码如下:
import scrapy
class CarSpider(scrapy.Spider):
name = 'car'
allowed_domains = ['car.autohome.com.cn']
start_urls = ['http://car.autohome.com.cn/']
def parse(self, response):
pass
但是这里的start_urls = ['http://car.autohome.com.cn/']中的地址和scrapy genspider创建时的地址就不一样,试了好多次都是这样,希望帮忙解决一下!万分感谢!
使用scrapy genspider命令创建爬虫文件时,第二个参数是爬虫的起始URL,这个URL会被用作爬虫的start_urls中的第一个元素。因此,你应该将start_urls设置为这样的值:
start_urls = ['https://car.autohome.com.cn/price/brand-15.html']
此时,爬虫就会从这个URL开始爬取。
师出同门,我也有这个问题,如果解决的话教一下,谢谢
不知道你这个问题是否已经解决, 如果还没有解决的话: