Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/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 2.7 scrapy xpath选择器问题_Python 2.7_Xpath_Scrapy Spider_Scrapy Shell - Fatal编程技术网

Python 2.7 scrapy xpath选择器问题

Python 2.7 scrapy xpath选择器问题,python-2.7,xpath,scrapy-spider,scrapy-shell,Python 2.7,Xpath,Scrapy Spider,Scrapy Shell,我使用调试爬行器设法找到了要隔离的属性,但我不确定是否正确地将其合并到我的爬行器中。当爬行器运行时,我没有收到明确的错误消息,所以我认为我只是正确地输入了选择器 我正在爬网的网站是“” 我在调试爬行器中键入的路径命令是“response.xpath('//div[@class=“show_sec_button”]/text()”),它提取我要查找的确切响应 这是我的蜘蛛: import scrapy from smiling_moose.items import SMItem class S

我使用调试爬行器设法找到了要隔离的属性,但我不确定是否正确地将其合并到我的爬行器中。当爬行器运行时,我没有收到明确的错误消息,所以我认为我只是正确地输入了选择器

我正在爬网的网站是“” 我在调试爬行器中键入的路径命令是“response.xpath('//div[@class=“show_sec_button”]/text()”),它提取我要查找的确切响应

这是我的蜘蛛:

import scrapy

from smiling_moose.items import SMItem

class Smspider (scrapy.Spider):
    name = "smspider"
    allowed_domains = ["http://www.smiling-moose.com/index.php"]
    start_urls = [
         "http://www.smiling-moose.com/events/index.php",
    ]

def parse(self, response):
    for sel in response.xpath('//div'):
        item = SMItem()
        item['desc'] = response.xpath('//*[@class="show_sec_band"]/text()').extract()
这是我的Items.py:

import scrapy


class SMItem(scrapy.Item):
    desc = scrapy.Field()
蜘蛛有什么我需要改变的吗?如果需要,我可以发布命令提示错误


谢谢

首先更改
允许的\u域

allowed_domains = ["smiling-moose.com"]
第二,返回项目:

item['desc'] = response.xpath('//*[@class="show_sec_band"]/text()').extract()
yield item