2017-03-23 4 views
1

私は希望者へのリンクをInterpol websiteから収集しました。約10kのリンクがあります。私はそれを非同期的にgrequestsとする方法を探しているので、1つずつ掻き集めるのに時間がかかります。grequests - 最初の2つの応答200 then 403

これは私のリンクリストのプレビューです:

今の
final_links[:20] 
['https://www.interpol.int/notice/search/wanted/2009-19572', 
'https://www.interpol.int/notice/search/wanted/2015-74196', 
'https://www.interpol.int/notice/search/wanted/2014-37667', 
'https://www.interpol.int/notice/search/wanted/2011-30019', 
'https://www.interpol.int/notice/search/wanted/2009-34171', 
'https://www.interpol.int/notice/search/wanted/2012-334072', 
'https://www.interpol.int/notice/search/wanted/2012-334068', 
'https://www.interpol.int/notice/search/wanted/2012-334070', 
'https://www.interpol.int/notice/search/wanted/2013-26064', 
'https://www.interpol.int/notice/search/wanted/2013-2528', 
'https://www.interpol.int/notice/search/wanted/2014-32597', 
'https://www.interpol.int/notice/search/wanted/2013-23413', 
'https://www.interpol.int/notice/search/wanted/2010-42146', 
'https://www.interpol.int/notice/search/wanted/2015-30555', 
'https://www.interpol.int/notice/search/wanted/2013-2514', 
'https://www.interpol.int/notice/search/wanted/2010-53288', 
'https://www.interpol.int/notice/search/wanted/2015-58805', 
'https://www.interpol.int/notice/search/wanted/2015-58807', 
'https://www.interpol.int/notice/search/wanted/2015-58803', 
'https://www.interpol.int/notice/search/wanted/2015-62307'] 

私はちょうど、各リンクあちこち応答を得るためにしようとしています:

unsent_request = (grequests.get(url) for url in final_links) 
results = grequests.map(unsent_request) 

結果の最初のカップルは、応答200ですが、そのほとんどは(すべてではないが)403である。それを許さないInterpolサーバーなのか、それとも私が何か間違っている(私はあまりにも欲張りですか?:))? requestsで1つずつ行くとうまくいきます。

答えて

2

これはウェブサイトの保護による可能性があります。あなたは本質的にそれらをプログラム的にスパムしています。だから彼らはあなたにいくつかの要求をさせ、悪い少年であることを禁じられている403をあなたに与えます。リターンステータスコードを確認して、403で小さな睡眠を行い、再度リクエストを試みると、毎回睡眠を増やすことができます。または、あなたはtorを介して要求を行い、403を受け取ったら回線を変更して新しい出口ノードを得ることができます。

+1

これは私が考えたものです。ありがとう。私は「倫理的な」スクレイパーであり続けます:) – pawelty

関連する問題