0
这是我的代码。蜘蛛不抓取网址或不提取它们或类似的东西。如果我但在“启动网址”目标网址然后scrapy发现项目,但不会向前爬行,如果我但“启动网址”包含目标列表的url,那么结果为0。 :)我希望文本不混淆Scrapy只抓取一页
from scrapy.spiders import Spider
from testing.items import TestingItem
import scrapy
class MySpider(scrapy.Spider):
name = 'testing'
allowed_domains = ['http://somewebsite.com']
start_urls = ['http://somewebsite.com/listings.php']
def parse(self, response):
for href in response.xpath('//h5/a/@href'):
full_url = response.urljoin(href.extract())
yield scrapy.Request(full_url, callback=self.parse_item)
def parse_item(self, response):
titles = response.xpath('//*[@class="panel-content user-info"]').extract()
for title in titles:
item = TestingItem()
item["nimi"] = response.xpath('//*[@class="seller-info"]/h3/text()').extract()
yield item
尝试删除allowed_domains中的'http://' –
尼斯,tanx伴侣:)。你知道我需要添加什么来分页到下一页吗? :) –