私はあなたの人がこれについてどう思うかを知りたいです。私は数日前から研究していて、どこに間違っているのか分からないようです。どんな助力も高く評価されます。Python Scrapy Spider:一貫性のない結果
このURLを体系的にクロールする:Question siteページネーションを使用して残りのページをクロールします。
私の現在のコード:
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.selector import Selector
from scrapy.spiders import CrawlSpider, Rule
from acer.items import AcerItem
class AcercrawlerSpider(CrawlSpider):
name = 'acercrawler'
allowed_domains = ['studyacer.com']
start_urls = ['http://www.studyacer.com/latest']
rules = (
Rule(LinkExtractor(), callback='parse_item', follow=True),
)
def parse_item(self, response):
questions= Selector(response).xpath('//td[@class="word-break"]/a/@href').extract()
for question in questions:
item= AcerItem()
item['title']= question.xpath('//h1/text()').extract()
item['body']= Selector(response).xpath('//div[@class="row-fluid"][2]//p/text()').extract()
yield item
私はそれがすべてのエラーを投げる代わりに、一貫性のない結果を出力しないクモを走りました。記事のページを2度掻き回すことがあります。私はそれが私が使用したセレクターと関係するかもしれないと思っていますが、私はこれ以上それを絞ることはできません。これで助けてください?