作者:大地瓜1975 | 来源:互联网 | 2023-09-23 19:29
请问一下 ,
class myspider(scrapy.Spider):
1 2 3 4 5 6 7 8 9
| name = 'novel'
allowed_domains = ['23wx.com']
bash_url = 'http://www.23wx.com/class/'
bashurl = '.html'
def start_requests(self):
for i in range(1, 11):
url = self.bash_url + str(i) + '_1' + self.bashurl
yield Request(url, self.getallurl) |
1 2
| def getallurl(self, response):
print response.body |
上面这个能正确输出html内容
但是下面这个却不能输出
class myspider(scrapy.Spider):
1 2 3 4 5 6 7 8 9
| name = 'novel'
allowed_domain = ['23wx.com']
def get_start_url(self):
for i in range(1,11):
url = 'http://www.23wx.com/class/{}_1.html'.format(i)
yield Request(url,callback=self.getallurl)
def getallurl(self,response):
print response.body |
实在不清楚两者之间有什么区别,还是回调函数的使用有什么注意的地方。求指教