ウェブサイトをスクラップしようとしたときに動的コンテンツに問題があります。私は、以下のものを使用して、私のScrapyにスプラッシュを追加するためにドッカーを使用:治療スパイダーは数分後に200応答を返します
https://blog.scrapinghub.com/2015/03/02/handling-javascript-in-scrapy-with-splash/
残念ながら、私はまだ理由は動的なコンテンツ(多分?)のコンテンツをキャプチャしていません。
私のコードは、実行されるコンテンツを取り込み、その後、4000ページの周りに掻き取った後、それだけでデータを持っているほとんどが次の6000ページで、このエラーが返されます。ここでは
[scrapy.core.engine] DEBUG: Crawled (200) <GET http://www...> (referer: None)
は私のクモコードです:
あなたがデータを取得していないファイルでimport scrapy
from scrapy_splash import SplashRequest
class PeopleSpider(scrapy.Spider):
name="people"
start_urls=[
'http://www.canada411.ca/res/%s/' % page for page in xrange(5192080000,5192090000)
]
def start_requests(self):
for url in self.start_urls:
yield SplashRequest(url, self.parse,
endpoint='render.html',
args={'wait': 2},
)
def parse(self,response):
for people in response.css('div#contact'):
yield{
'name': people.css('h1.vcard__name::text').extract_first().strip().title(),
'address': people.css('div.vcard__address::text').extract_first().strip().split(',')[0].strip(),
'city': people.css('div.vcard__address::text').extract_first().strip().split(',')[1].strip().split(' ')[0].strip(),
'province': people.css('div.vcard__address::text').extract_first().strip().split(',')[1].strip().split(' ')[1].strip(),
'postal code': people.css('div.vcard__address::text').extract_first().split(',')[2].strip().replace(' ',''),
'phone': people.css('span.vcard__label::text').extract_first().replace('(','').replace(')','').replace('-','').replace(' ',''),
}
おそらく、あなたが掻き集めているサイトがcaptchasを表示し始めている可能性があります – Umair
興味深い、これに対する解決策はありますか? –
私はコード/ソリューションを投稿できません。データを取得していないときにレスポンスのHTMLを保存してブラウザにそのHTMLファイルを開いて名前、アドレスなどがそのページに存在しない理由を確認することをお勧めします – Umair