Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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_Scrapy - Fatal编程技术网

Python Scrapy没有跟随下一个解析函数

Python Scrapy没有跟随下一个解析函数,python,scrapy,Python,Scrapy,我正试图编写一个简单的刮脚本,用我需要的技术刮去谷歌夏季的代码组织。其工作正在进行中。我的解析函数工作正常,但每当我回调到org函数时,它不会抛出任何输出 # -*- coding: utf-8 -*- import scrapy class GsocSpider(scrapy.Spider): name = 'gsoc' allowed_domains = ['https://summerofcode.withgoogle.com/archive/2018/organiz

我正试图编写一个简单的刮脚本,用我需要的技术刮去谷歌夏季的代码组织。其工作正在进行中。我的解析函数工作正常,但每当我回调到org函数时,它不会抛出任何输出

# -*- coding: utf-8 -*-
import scrapy



class GsocSpider(scrapy.Spider):
    name = 'gsoc'
    allowed_domains = ['https://summerofcode.withgoogle.com/archive/2018/organizations/']
    start_urls = ['https://summerofcode.withgoogle.com/archive/2018/organizations/']
    def parse(self, response):
        for href in response.css('li.organization-card__container a.organization-card__link::attr(href)'):
            url = response.urljoin(href.extract())
            yield scrapy.Request(url, callback = self.parse_org)

    def parse_org(self,response):
        tech=response.css('li.organization__tag organization__tag--technology::text').extract()
    #if 'python' in tech:
        yield
        {
        'name':response.css('title::text').extract_first()
        #'ideas_list':response.css('')
    }

首先,您配置的
允许的\u域不正确,如下所示:

包含此爬行器所属域的字符串的可选列表 允许爬行。请求不属于域名的URL 如果发生以下情况,将不遵循此列表中指定的(或其子域) OffItemIDdleware已启用

假设您的目标url为,然后添加 “example.com”添加到列表中

如您所见,您只需要包括域,这是一个过滤功能(这样其他域就不会被爬网)。这也是可选的,所以我建议不要包含它

另外,您获取
tech
css
不正确,应该是:

li.organization__tag.organization__tag--technology

我在解析中的for循环中没有看到缩进。在SO中复制缩进时出错,或者在代码中按原样复制缩进?复制时出错。抱歉。然后@eLRuLL给出了更好的答案:)我可以转到下一个链接,但它既没有删除页面标题也没有删除技术。我为此更改了csstoo@sam007如果答案对你有帮助,请记住接受它。谢谢