2017-04-27 31 views
0

これは私のコードです。スパイダーは、それらを抽出しないか、そういうものを抽出しません。もし私が "start urls"でurlを検索したら、scrapyはアイテムを見つけますが、前方にはクロールしません。そして、 "url"を始めるとターゲットリストを含むurlを返します。 :)私は、テキストはあなたがallowed_domainshttp://を削除する必要がScrapyは1ページのみクロールします

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 
+1

allowed_domains –

+1

ニースtanx mate :)の「http://」を削除してください。次のページに改ページするために必要なものが分かっていますか? :) –

答えて

1

を混乱されていないことを願っています。

paginationについては、Rulesをご利用ください。ご質問hereをご確認いただきますようお願いいたします。それはあなたがページネーションを簡単に通過できるようになります。

リトルexemple:

rules = (Rule(LinkExtractor(allow=(), restrict_xpaths=('xpath/to/nextpage/button',)), callback="parse", follow= True),) 

この情報がお役に立てば幸いです。

+1

ニース!それは完璧な男です! Tanxたくさん! :) –

関連する問題