【问题标题】:Scrapy shell error how to fix it how to use this type of urlScrapy shell错误如何解决如何使用这种类型的url
【发布时间】:2021-11-17 12:54:50
【问题描述】:

嗨,我是网络抓取的初学者,我刚刚学习 scrapy。当我尝试在scrapy shell中使用这种类型的url时,它总是显示一个错误如何绕过它

scrapy shell https://www.yellowpages.com/search?search_terms=software+engineer&geo_location_terms=Glendale%2C+CA 
At line:1 char:79
+ ... ://www.yellowpages.com/search?search_terms=software+engineer&geo_loca ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") 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+engineer&geo_location_terms=Glendale%2C+CA']

    def parse(self, response):
        pass

【问题讨论】:

    标签: python web-scraping scrapy screen-scraping


    【解决方案1】:

    只需将网址用引号括起来:

    scrapy shell "https://www.yellowpages.com/search?search_terms=software+engineer&geo_location_terms=Glendale%2C+CA"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-15
      • 2017-01-05
      相关资源
      最近更新 更多