Python源码中爬虫没效果问题出在哪里,python爬虫,item.pypytho
Python源码中爬虫没效果问题出在哪里,python爬虫,item.pypytho
item.py
python-*- coding: utf-8 -*import scrapyclass BokeItem(scrapy.Item): url=scrapy.Field() title=scrapy.Field() content=scrapy.Field()
boke_spider.py
python-*- coding: utf-8 -*-from scrapy.contrib.spiders import CrawlSpider ,Rulefrom scrapy.contrib.linkextractors import LinkExtractorfrom boke.items import BokeItemclass BokeItem(CrawlSpider): name = 'blog' start_urls =['http://blog.sina.com.cn/s/blog_4701280b0102eo83.html'] def parse_torrent(self,response): torrent=BokeItem() torrent['url']=response.url torrent['title']=response.xpath("//h2[@class='titName SG_txta']/text()").extract()[0] torrent['content']=response.xpath("//div[@style='min-height:22px']/text()").extract()[0] return torrent
试试看看这个博客,专门针对scrapy的
试试去看看官方doc
from scrapy.contrib.spiders import CrawlSpider ,Rule
你调用的是CrawlSpider类,但是显然没有写任何的规则
建议改为Spider类,并将parse_torrent改名为parse,如下:
from scrapy.contrib.spiders import Spiderfrom boke.items import BokeItemclass BokeItem(Spider):
编橙之家文章,
相关内容
- Python子线程停止方法问题,python线程停止,发现 threadi
- Python scrapy框架ImagesPipeline图片下载保存名称问题,,仔细
- python菜鸟求问关于嵌套函数中作用域范围应该怎么理解
- Python3.X中没sqlite3模块吗?为什么我导入时会提示没有模
- 求python列表倒序输的方法,python列表倒序输,想请问下
- Python锁问题,并发只读有锁吗怎么避免,python锁,python并
- Python列表中元素数量如何统计,python列表元素数量,比如
- mysql怎么把对因汉字部分的unicode换成utf8呢,unicodeutf8
- python 字典形式字符串最佳格式转换方法是什么,pytho
- 请大家给个做vpn server的思路,能讲讲vpn原理最好,serv
评论关闭