#python #web-scraping #scrapy #screen-scraping
Вопрос:
Привет, я новичок в веб-скребке, я только учусь скребку. Когда я пытаюсь использовать этот тип URL-адреса в оболочке scrapy, он всегда показывает ошибку, как ее обойти
scrapy shell https://www.yellowpages.com/search?search_terms=software engineeramp;geo_location_terms=Glendale, CA
At line:1 char:79
... ://www.yellowpages.com/search?search_terms=software engineeramp;geo_loca ...
~
The ampersand (amp;) character is not allowed. The amp; operator is reserved for future use; wrap an ampersand in double quotation marks ("amp;") to pass it as part of a string.
CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : AmpersandNotAllowed
дерьмовый код
import scrapy
class YellowSpider(scrapy.Spider):
name = 'yellow'
allowed_domains = ['yellowpages.com']
start_urls = ['https://www.yellowpages.com/search?search_terms=software engineeramp;geo_location_terms=Glendale, CA']
def parse(self, response):
pass
Ответ №1:
Просто заключите URL-адрес в кавычки:
scrapy shell "https://www.yellowpages.com/search?search_terms=software engineeramp;geo_location_terms=Glendale, CA"