早上好!
我用Scrapy开发了一个非常简单的蜘蛛,只是想与FormRequest一起使用。我正在尝试向以下页面发送请求:https://www.caramigo.eu/,这将导致我进入这样的页面:https://www.caramigo.eu/be/fr/recherche?address=Belgique%2C+Li%C3%A8ge&date_debut=16-03-2019&date_fin=17-03-2019。问题是我的蜘蛛无法正确提示页面(汽车图像和信息根本不显示),因此我无法从中收集任何数据。这是我的蜘蛛:
import scrapy
class CarSpider(scrapy.Spider):
name = "caramigo"
def start_requests(self):
urls = [
'https://www.caramigo.eu/'
]
for url in urls:
yield scrapy.Request(url=url, callback=self.search_line)
def search_line(self, response):
return scrapy.FormRequest.from_response(
response,
formdata={'address': 'Belgique, Liège', 'date_debut': '16-03-2019', 'date_fin': '17-03-2019'},
callback=self.parse
)
def parse(self, response):
filename = 'caramigo.html'
with open(filename, 'wb') as f:
f.write(response.body)
self.log('Saved file %s' % filename)
很抱歉,如果语法不正确,我对编码还很陌生。
提前谢谢!