【发布时间】:2015-07-31 22:32:56
【问题描述】:
您好,我使用 scrapy 来抓取 paginasamarillas.es,但没有得到结果,这些是我的代码。请问您能帮我解决这个问题吗?
from scrapy.item import Item, Field
class AyellItem(Item):
name = Field()
pass
这是蜘蛛
from scrapy.selector import HtmlXPathSelector
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.contrib.spiders import CrawlSpider, Rule
from ayell.items import AyellItem
class YellSpider(CrawlSpider):
name = 'yell'
allowed_domains = ['http://www.paginasamarillas.es']
start_urls = ['http://www.paginasamarillas.es/alimentacion/all-ma/all-pr/all-is/all-ci/all-ba/all-pu/all-nc/1']
def parse_items(self, response):
hxs = HtmlXPathSelector(response)
directors = hxs.select("/html/body")
items = []
for directors in directors:
item = AyellItem()
item ["name"] = directors.select("/h1").extract()
items.append(item)
return items
这就是我得到的
2015-07-31 19:11:25-0300 [大喊] 调试:已爬网 (200) http://www.paginasamarillas.es/alimentacion/all-ma/all-pr/all-is/all- ci/all-ba/all-pu/all-nc/1> (参考:无) 2015-07-31 19:11:25-0300 [yell] INFO:关闭蜘蛛(已完成) 2015-07-31 19:11:25-0300 [大喊] 信息:转储蜘蛛统计信息:{'downloader/request_bytes':267,'downloader/request_count':1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 30509, 'downloader/response_count': 1, 'downloader/response_status_count/200': 1, 'finish_reason': “完成”,“完成时间”: datetime.datetime(2015, 7, 31, 22, 11, 25, 731485), 'scheduler/memory_enqueued': 1,
【问题讨论】: