响应 scrapy 的不同结果 shell
different result in response scrapy shell
当我开始 scrapy 时,我正在尝试获取汽车的价格。
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
当然,此网站会根据 headers 或其他客户详细信息以不同方式处理请求。例如。价格货币基于您所在的位置。
通过以下命令查看您使用浏览器获得的响应:
view(response)
价格应该和你用Scrapy的解析器得到的一样。
您可以尝试发出尽可能接近浏览器请求的请求(使用相同的 User-Agent
和 Accept
headers)以获得相同的价格值.
希望对您有所帮助。
当我开始 scrapy 时,我正在尝试获取汽车的价格。
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
当然,此网站会根据 headers 或其他客户详细信息以不同方式处理请求。例如。价格货币基于您所在的位置。 通过以下命令查看您使用浏览器获得的响应:
view(response)
价格应该和你用Scrapy的解析器得到的一样。
您可以尝试发出尽可能接近浏览器请求的请求(使用相同的 User-Agent
和 Accept
headers)以获得相同的价格值.
希望对您有所帮助。