关于scrapy的爬虫

Nature-Coder-Porter 2016-05-03 03:08:09
spider代码如下:
class FuncSpider(CrawlSpider):
name="fund"
allowed_domains="fund.eastmoney.com"
start_urls=["http://fund.eastmoney.com/fund.html"]
rules=[
Rule(SgmlLinkExtractor(allow=("fund.html")),follow=True,callback='parse_item')]

def parse_item(self,response):
items=[]
sel=Selector(response)
sites=sel.xpath('//div[@id="tableDiv"]/table/tbody/tr')
for site in sites:
item=FundItem()
item['code']=site.css('.bzdm').xpath('text()').extract()[0]
item['name']=site.xpath('//td[5]/nobr/a/text()').extract()[0]
item['new_dwjz']=site.xpath('//td[6]/text()').extract()[0]
item['new_ljjz']=site.xpath('//td[7]/text()').extract()[0]
item['old_dwjz']=site.xpath('//td[8]/text()').extract()[0]
item['old_ljjz']=site.xpath('//td[9]/text()').extract()[0]
item['rzzz']=site.xpath('//td[10]/text()').extract()[0]
item['rzzl']=site.xpath('//td[11]/text()').extract()[0]
items.append(item)

return items


def _process_request(self, request):
info('process ' + str(request))
return request
问题:
我用scrapy shell 可以获取数据,但是这个获取不了数据,调试的时候没有进入parse_item函数,估计是rules写的有问题,有哪位大神知道哪里写错了,求告知,不甚感激!!!
...全文
54 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧