6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ScrapyでのUser-Agentの変更

Posted at

#User-Agentの変更
デフォルトでは、settings.pyに指定がないので、Scrapyのバージョンがそのまま使われます。

例)

***.***.***.*** - - [18/Mar/2017:23:07:21 -0400] "GET / HTTP/1.1" 200 68 "-" "Scrapy/1.3.2 (+http://scrapy.org)"

例えば、settings.pyに以下のように指定します。

settings.py
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8'

再度クロールしてみると、以下のようになりました。

***.***.***.*** - - [18/Mar/2017:23:19:03 -0400] "GET / HTTP/1.1" 200 68 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?