问题描述
当我开始抓狂的时候,我试图得到一辆汽车的价格。
scrapy shell https://www.rentalcars.com/SearchResults.do?country=Argentina&doYear=2018&doFiltering=true&exSuppliers=&fromLocChoose=true&filterTo=49&dropLocationName=Buenos+Aires&emptySearchResults=false&ftsType=C&longitude=-58.3816&ftsLocationSearch=51&dropFtsSearch=L&doDay=25&chinese-license=on&searchType=allareasgeosearch&filterFrom=0&puMonth=9&dropFtsInput=buenos+&dropCountry=Argentina&puDay=24&dropFtsLocationSearch=51&puHour=10&doMonthYear=9-2018&dropFtsEntry=18908&filterCoordinates=-34.44103514%2C-58.8644886&enabler=&puMonthYear=9-2018&distance=10&reducedCategory=small&ftsEntry=18908&city=Buenos+Aires&ordering=price&latitude=-34.6038&filterName=CarCategorisationSupplierFilter&dropCity=Buenos+Aires&dropFtsType=C&ftsAutocomplete=Buenos+Aires%2C+Argentina&driversAge=30&dropFtsAutocomplete=Buenos+Aires%2C+Argentina&dropFtsLocationName=Buenos+Aires&dropCountryCode=&countryCode=&doMinute=0&advSearch=&filterAdditionalInfo=&puYear=2018&puSameAsDo=on&locationName=Buenos+Aires&puMinute=0&ftsInput=buenos+&coordinates=-34.6038%2C-58.3816&dropLocation=-1&doHour=10&dropCoordinates=-34.6038%2C-58.3816&ftsLocationName=Buenos+Aires&ftsSearch=L&location=-1&doMonth=9
fetch('https://www.rentalcars.com/SearchResults.do?country=Argentina&doYear=2018&doFiltering=true&exSuppliers=&fromLocChoose=true&filterTo=49&dropLocationName=Buenos+Aires&emptySearchResults=false&ftsType=C&longitude=-58.3816&ftsLocationSearch=51&dropFtsSearch=L&doDay=25&chinese-license=on&searchType=allareasgeosearch&filterFrom=0&puMonth=9&dropFtsInput=buenos+&dropCountry=Argentina&puDay=24&dropFtsLocationSearch=51&puHour=10&doMonthYear=9-2018&dropFtsEntry=18908&filterCoordinates=-34.44103514%2C-58.8644886&enabler=&puMonthYear=9-2018&distance=10&reducedCategory=small&ftsEntry=18908&city=Buenos+Aires&ordering=price&latitude=-34.6038&filterName=CarCategorisationSupplierFilter&dropCity=Buenos+Aires&dropFtsType=C&ftsAutocomplete=Buenos+Aires%2C+Argentina&driversAge=30&dropFtsAutocomplete=Buenos+Aires%2C+Argentina&dropFtsLocationName=Buenos+Aires&dropCountryCode=&countryCode=&doMinute=0&advSearch=&filterAdditionalInfo=&puYear=2018&puSameAsDo=on&locationName=Buenos+Aires&puMinute=0&ftsInput=buenos+&coordinates=-34.6038%2C-58.3816&dropLocation=-1&doHour=10&dropCoordinates=-34.6038%2C-58.3816&ftsLocationName=Buenos+Aires&ftsSearch=L&location=-1&doMonth=9')
我试图获得价值
response.css('span[class="carResultRow_Price-now"]::text').extract()
结果与网站上显示的结果不同
['\n\t\t ARS1,584.37']
正确值为1,563.03
1楼
当然,此站点根据标头或其他客户端详细信息来处理请求的方式也有所不同。 例如。 计价货币基于您所在的位置。 查看使用浏览器并通过以下命令获得的响应:
view(response)
价格应与Scrapy解析器的价格相同。
您可以尝试使请求看起来与浏览器请求尽可能接近(使用相同的User-Agent
和Accept
标头),以获取相同的价格值。
希望能帮助到你。