Scrapy 1.5.1
Python 2.7.6
. 我试着从下面的代码中提取用户名
page
我实现了以下代码:
# -*- coding: utf-8 -*-
import scrapy
from scrapy.http import Request
class BtctalkspiderSpider(scrapy.Spider):
name = 'btctalkSpider'
allowed_domains = ['bitcointalk.org']
max_uid = 10
def parse(self, response):
urls = response.xpath("//a/@href").extract()
for i in range(self.max_uid):
# scrapy shell "https://bitcointalk.org/index.php?action=profile;u=1"
yield Request('https://bitcointalk.org/index.php?action=profile;u=%d' % i, callback=self.parse_application)
def parse_application(self, response):
userName = response.xpath('//td[normalize-space(.)="Name:"]/following-sibling::td/text()').extract()
yield {
'userName': userName
}
[]
回来。
我检查了我的房间
xpath
通过外壳,一切似乎都正常。
有什么建议我做错了什么吗?