scrapy-random-useragent

Scrapy Middleware to set a random User-Agent for every Request.

  • Owner: cnu/scrapy-random-useragent
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Scrapy Random User-Agent

Does your scrapy spider get identified and blocked by servers because
you use the default user-agent or a generic one?

Use this random_useragent module and set a random user-agent for
every request. You are limited only by the number of different
user-agents you set in a text file.

Installing

Installing it is pretty simple.

.. code-block:: python

pip install scrapy-random-useragent

Usage

In your settings.py file, update the DOWNLOADER_MIDDLEWARES
variable like this.

.. code-block:: python

DOWNLOADER_MIDDLEWARES = {
    'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
    'random_useragent.RandomUserAgentMiddleware': 400
}

This disables the default UserAgentMiddleware and enables the
RandomUserAgentMiddleware.

Then, create a new variable USER_AGENT_LIST with the path to your
text file which has the list of all user-agents
(one user-agent per line).

.. code-block:: python

USER_AGENT_LIST = "/path/to/useragents.txt"

Now all the requests from your crawler will have a random user-agent
picked from the text file.

Main metrics

Overview
Name With Ownercnu/scrapy-random-useragent
Primary LanguagePython
Program languagePython (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2014-12-25 12:29:23
Pushed At2019-08-16 21:29:30
Last Commit At2016-06-11 12:44:40
Release Count2
Last Release Name0.2 (Posted on 2016-06-11 12:44:50)
First Release Name0.1 (Posted on 2014-12-25 20:07:38)
用户参与
Stargazers Count202
Watchers Count9
Fork Count48
Commits Count13
Has Issues Enabled
Issues Count7
Issue Open Count6
Pull Requests Count2
Pull Requests Open Count3
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private