2013-04-21 16 views
6

を使用して: http://www.aido.com/eshop/cl_2-c_189-p_185/stationery/pens.htmlページネーションが、私はこのウェブサイトをクロールしようとしているscrapy

私は、このページにすべての製品を得ることができますが、どのように私は、ページの下部にある「もっと見る」リンクのための要求を発行します?今まで

私のコードは次のとおりです。

rules = (
    Rule(SgmlLinkExtractor(restrict_xpaths='//li[@class="normalLeft"]/div/a',unique=True)), 
    Rule(SgmlLinkExtractor(restrict_xpaths='//div[@id="topParentChilds"]/div/div[@class="clm2"]/a',unique=True)), 
    Rule(SgmlLinkExtractor(restrict_xpaths='//p[@class="proHead"]/a',unique=True)), 
    Rule(SgmlLinkExtractor(allow=('http://[^/]+/[^/]+/[^/]+/[^/]+$',), deny=('/about-us/about-us/contact-us', './music.html', ) ,unique=True),callback='parse_item'), 
) 

任意のヘルプ?

答えて

10

まず第一に、あなたは、AJAX、動的にロードされたコンテンツをこするに対処する方法については、このスレッドを見てみる必要があります。 Can scrapy be used to scrape dynamic content from websites that are using AJAX?

ので、「もっと見る」のボタン火災アップXHRリクエストをクリック:

http://www.aido.com/eshop/faces/tiles/category.jsp?q=&categoryID=189&catalogueID=2&parentCategoryID=185&viewType=grid&bnm=&atmSize=&format=&gender=&ageRange=&actor=&director=&author=&region=&compProductType=&compOperatingSystem=&compScreenSize=&compCpuSpeed=&compRam=&compGraphicProcessor=&compDedicatedGraphicMemory=&mobProductType=&mobOperatingSystem=&mobCameraMegapixels=&mobScreenSize=&mobProcessor=&mobRam=&mobInternalStorage=&elecProductType=&elecFeature=&elecPlaybackFormat=&elecOutput=&elecPlatform=&elecMegaPixels=&elecOpticalZoom=&elecCapacity=&elecDisplaySize=&narrowage=&color=&prc=&k1=&k2=&k3=&k4=&k5=&k6=&k7=&k8=&k9=&k10=&k11=&k12=&startPrize=&endPrize=&newArrival=&entityType=&entityId=&brandId=&brandCmsFlag=&boutiqueID=&nmt=&disc=&rat=&cts=empty&isBoutiqueSoldOut=undefined&sort=12&isAjax=true&hstart=24&targetDIV=searchResultDisplay 

これは、次の24項目のうちtext/htmlを返します。このhstart=24のパラメータに注意してください。初めて「もっと見る」をクリックすると、それは24、2回目--48などです。これはあなたの救命救助者になるはずです。

ここであなたのスパイダーでこれらの要求をシミュレートする必要があります。これを行うための推奨される方法は、データを抽出するコールバックを提供するスクラピーのRequestオブジェクトをインスタンス化することです。

希望に役立ちます。

+1

これは役に立ちましたが、「スクラピーのリクエストオブジェクトをインスタンス化する」方法の例がさらに役立っていました。 – SMPLGRP

関連する問題