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