-5
主URL = [https://www.amazon.in/s/ref=nb_sb_ss_i_1_8?url=search-alias%3Dcomputers&field-keywords=lenovo+laptop&sprefix=lenovo+m%2Cundefined%2C2740&crid=3L1Q2LMCKALCT]どのように治療のURLのURLをクロールするには?
主URLから抽出されたURL = [http://www.amazon.in/Lenovo-Ideapad-15-6-inch-Integrated-Graphics/dp/B01EN6RA7W?ie=UTF8&keywords=lenovo%20laptop&qid=1479811190&ref_=sr_1_1&s=computers&sr=1-1]
import scrapy
from product.items import ProductItem
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
class amazonSpider(scrapy.Spider):
name = "amazon"
allowed_domains = ["amazon.in"]
start_urls = [ main url here]
def parse(self, response):
item=ProductItem()
for content in response.xpath("sample xpath"):
url = content.xpath("a/@href").extract()
request = scrapy.Request(str(url[0]),callback=self.page2_parse)
#url is extracted from my main url
item['product_Rating'] = request
yield item
def page2_parse(self,response):
#here i dint get the response for the second url content
for content in response.xpath(sample xpath):
yield content.xpath(sample xpath).extract()
第二の機能は、ここで実行していません。私を助けてください。
ここPage2_paseは、2番目のURLを取得されていないと私はさらにクロールすることはできません –
「URLのURLをこするが、」本当にありません。第2のURLは、第1のURLと同じ哲学で削り取られます。 – blacksite
こんにちは、最初のURLだけをクロールした後に2番目のURLを取得しました。私のメインURLの例では、複数の製品[ラップトップ]を見ることができます。だからメインのURLをクロールした後、私は各製品の詳細ページのURLを取得します。 –