Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Scrapy缺少一个位置参数响应_Python_Python 3.x_Web Scraping_Scrapy - Fatal编程技术网

Python Scrapy缺少一个位置参数响应

Python Scrapy缺少一个位置参数响应,python,python-3.x,web-scraping,scrapy,Python,Python 3.x,Web Scraping,Scrapy,我想将所有链接存储在my\u links变量中。但我试图存储的一个,他们给了我错误。缺少一个位置参数响应。我是新来的刮痧。。。请帮忙。。。这是我的密码 import scrapy 从scrapy.crawler导入crawler进程 类别:刮刀(刮刀、蜘蛛): name=“udemy\u刮刀” 起始URL=['https://couponscorpion.com/'] def解析(自我,响应): 对于response.xpath(“//div[@class=“rh post wrapper”]”

我想将所有链接存储在my\u links变量中。但我试图存储的一个,他们给了我错误。缺少一个位置参数响应。我是新来的刮痧。。。请帮忙。。。这是我的密码

import scrapy
从scrapy.crawler导入crawler进程
类别:刮刀(刮刀、蜘蛛):
name=“udemy\u刮刀”
起始URL=['https://couponscorpion.com/']
def解析(自我,响应):
对于response.xpath(“//div[@class=“rh post wrapper”]”中的链接:
屈服{
“名称”:links.xpath(“.//a/text()”).extract(),
}
my_links=parse()

提前感谢

您不需要调用
parse
方法,因为它是回调方法,可以调用
start\u URL
列表中的所有URL。您可以在爬行器级别创建一个列表。这会奏效的

import scrapy
from scrapy.crawler import CrawlerProcess


class Udemy_Scraper(scrapy.Spider):
    name = "udemy_scraper"
    my_links = []
    start_urls = ['https://couponscorpion.com/']
    def parse(self, response):
        for links in response.xpath('//div[@class="rh-post-wrapper"]'):
            self.my_links + =[{'name': links.xpath('.//a/text()').extract()}]
        yield self.my_links