何らかの理由で、Splashを使用しているときに何らかの要求があったとしても、私は403を持っています。私は間違っている?Scrapy + Splash return 403任意のサイトについて
https://github.com/scrapy-plugins/scrapy-splash後、私はすべての設定を設定する:8050 scrapinghub /スプラッシュ
スパイダーコード:
SPLASH_URL = 'http://localhost:8050'
DOWNLOADER_MIDDLEWARES = {
'scrapy_splash.SplashCookiesMiddleware': 723,
'scrapy_splash.SplashMiddleware': 725,
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
}
SPIDER_MIDDLEWARES = {
'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
}
DUPEFILTER_CLASS = 'scrapy_splash.SplashAwareDupeFilter'
HTTPCACHE_STORAGE = 'scrapy_splash.SplashAwareFSCacheStorage'
は8050 -pドッキングウィンドウ
sudoのドッキングウィンドウの実行とスプラッシュ開始しました:
import scrapy from scrapy import Selector from scrapy_splash import SplashRequest class VestiaireSpider(scrapy.Spider): name = "vestiaire" base_url = "https://www.vestiairecollective.com" rotate_user_agent = True def start_requests(self): urls = ["https://www.vestiairecollective.com/men-clothing/jeans/"] for url in urls: yield SplashRequest(url=url, callback=self.parse, meta={'args': {"wait": 0.5}}) def parse(self, response): data = Selector(response) category_name = data.xpath('//h1[@class="campaign campaign-title clearfix"]/text()').extract_first().strip() self.log(category_name)
それから私はクモを実行します。[
2017年12月19日午後10時55分17秒:
scrapyクロールテスト
をしてURLを要求するための403を取り戻します[scrapy.utils.log] INFO:Scrapy 1.4.0が起動しました (bot:crawlers)2017-12-19 22:55:17 [scrapy.utils.log] INFO: オーバーライドされた設定:{'DUPEFILTER_CLASS': 'scrapy_splash .SplashAwareDupeFilter '、' CONCURR ENT_REQUESTS ':10、 'NEWSPIDER_MODULE': ' ': [' crawlers.spiders'] 'ROBOTSTXT_OBEY':真、 'COOKIES_ENABLED crawlers.spiders'、' SPIDER_MODULES': 偽、 'BOT_NAME': 'クローラ' 'HTTPCACHE_STORAGE': 'scrapy_splash.SplashAwareFSCacheStorage'} 2017年12月19日午後09時55分17秒 [scrapy.middleware] INFO:有効拡張子: [ 'scrapy.extensions.telnet.TelnetConsole'、 「scrapy.extensions。 [scrapy.middleware] INFO:Enabledダウンロード済みミドルウェア: ['scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware'、 'scrapy .downloadermiddlewares.httpauth.HttpAuthMiddleware ' 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware'、 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware'、 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware'、 ' scrapy.downloadermiddlewares.retry.RetryMiddleware 」、 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware'、 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware'、 'scrapy_splash.SplashCookiesMiddleware'、 'scrapy_splash.SplashMiddleware'、 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware'、 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware'、 'scrapy.downloadermiddlewares.stats.DownloaderStats'] 2017年12月19日22時55分17秒 [scrapy.middleware] INFO:有効クモミドルウェア: [ 'scrapy.spidermiddlewares.httperror.HttpErrorMiddleware'、 'scrapy_splash.SplashDeduplicateArgsMiddleware' 、 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware' 'scrapy.spidermiddlewares.referer.RefererMiddleware' 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware' 'scrapy.spidermiddlewares.depth.DepthMiddleware'] 2017年12月19日22:55:17 [治療。ミドルウェア] INFO:有効なアイテムのパイプライン: ['scrapy.pipelines.images.ImagesPipeline'] 2017-12-19 22:55:17 [scrapy.core.engine] INFO:Spider opened 2017-12-19 22:55 :17 [scrapy.extensions.logstats]情報:クロールされた0ページ(0ページ/分)、 0件(0件/分)2017-12-19 22:55:17 [scrapy.extensions。 telnet] DEBUG:Telnetコンソールで聴いている 127.0.0.1:6023 2017-12-19 22:55:20 [scrapy.core.engine] DEBUG:クロール済み(200)https://www.vestiairecollective.com/robots.txt >(referer: なし)2017-12-19 22:55:22 [scrapy.core.engine] DEBUG:クロール済み(403) http:// localhost:8050/robots.txt>(referer:なし)2017- 12-19 22:55:23 [scrapy.core.engine] DEBUG:クロール済み(403)https://www.vestiairecollective.com/men-clothin G /ジーンズ/経由 http://localhost:8050/render.html>(リファラー:なし)2017年12月19日22時55分23秒 [scrapy.spidermiddlewares.httperror] INFO:無視応答 https://www.vestiairecollective.com/men-clothing/jeans/>:HTTPステータス コードが処理されていませんか許可された2017-12-19 22:55:23 [scrapy.core.engine] INFO:閉じるスパイダー(仕上げ)2017-12-19 22:55:23 [scrapy.statscollectors] INFO:ダンプの統計情報: { 'downloader/request_bytes':1254、 'downloader/request_count':3、 'downloader/request_method_count/GET':2、 'downloader/request_method_count/POST':1、 'downloader/response_bytes':2793、 'ダウンローダ/ response_count ':3、 ' downloader/response_status_count/200 ':1、 ' downloader/response_status_count/403 ':2、' finish_reason ': '完了 '、' finish_time ':datetime.datetime(2017,12,19,20,55, 23,440598) 'httperror/response_ignored_count':1、 'httperror/response_ignored_status_count/403':1、 'log_count/DEBUG': 4 'log_count/INFO':8、 'MEMUSAGE /最大':53850112、 'MEMUSAGE /スタートアップ' [スケジューラ/エンキュー/メモリ]:2、 'スプラッシュ:スケジューラ/エンキューされた':2、 'スケジューラ/エンキュー/メモリ':2、 'スケジューラ/エンキュー/メモリ':2、 'スケジューラ/エンキュー/メモリ':2、 '/start_time ': datetime.datetime(2017、12、19、20、55、17、372080)} 2017:/render.html/request_count':1、 'splash/render.html/response_count/403':1、 'start_time' -12-19 22:55:23 [scrapy.core.engine] INFO:Spider closed(finished)
あなたはscrapyの 'settings.py'で' ROBOTSTXT_OBEY = False'を試しましたか? –
また、スプラッシュのドキュメント:Do not forget、OS XまたはWindowsでDockerマシンを使用している場合、これをDockerの仮想マシンのIPアドレスに設定する必要があります。例えば、 SPLASH_URL = ' http://192.168.59.103:8050/ ' –
'ROBOTSTXT_OBEY = False'同じ問題があります –