Use a random User-Agent provided by fake-useragent every request
Project description
.. image:: https://badge.fury.io/py/scrapy-fake-useragent.svg
:target: http://badge.fury.io/py/scrapy-fake-useragent
:alt: PyPI version
.. image:: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements.svg?branch=master
:target: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements/?branch=master
:alt: Requirements Status
scrapy-fake-useragent
=====================
Random User-Agent middleware based on
`fake-useragent <https://pypi.python.org/pypi/fake-useragent>`__. It
picks up ``User-Agent`` strings based on `usage
statistics <http://www.w3schools.com/browsers/browsers_stats.asp>`__
from a `real world database <http://useragentstring.com/>`__.
Configuration
-------------
Turn off the built-in ``UserAgentMiddleware`` and add
``RandomUserAgentMiddleware``.
In Scrapy >=1.0:
::
DOWNLOADER_MIDDLEWARES = {
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 400,
}
In Scrapy <1.0:
::
DOWNLOADER_MIDDLEWARES = {
'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 400,
}
Usage with `scrapy-proxies`
-------------
To use with middlewares of random proxy such as `scrapy-proxies <https://github.com/aivarsk/scrapy-proxies>`_, you need:
1. set ``RANDOM_UA_PER_PROXY`` to True to allow switch per proxy
2. set priority of ``RandomUserAgentMiddleware`` to be greater than ``scrapy-proxies``, so that proxy is set before handle UA
.. |GitHub version| image:: https://badge.fury.io/gh/alecxe%2Fscrapy-fake-useragent.svg
:target: http://badge.fury.io/gh/alecxe%2Fscrapy-fake-useragent
.. |Requirements Status| image:: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements.svg?branch=master
:target: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements/?branch=master
:target: http://badge.fury.io/py/scrapy-fake-useragent
:alt: PyPI version
.. image:: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements.svg?branch=master
:target: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements/?branch=master
:alt: Requirements Status
scrapy-fake-useragent
=====================
Random User-Agent middleware based on
`fake-useragent <https://pypi.python.org/pypi/fake-useragent>`__. It
picks up ``User-Agent`` strings based on `usage
statistics <http://www.w3schools.com/browsers/browsers_stats.asp>`__
from a `real world database <http://useragentstring.com/>`__.
Configuration
-------------
Turn off the built-in ``UserAgentMiddleware`` and add
``RandomUserAgentMiddleware``.
In Scrapy >=1.0:
::
DOWNLOADER_MIDDLEWARES = {
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 400,
}
In Scrapy <1.0:
::
DOWNLOADER_MIDDLEWARES = {
'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 400,
}
Usage with `scrapy-proxies`
-------------
To use with middlewares of random proxy such as `scrapy-proxies <https://github.com/aivarsk/scrapy-proxies>`_, you need:
1. set ``RANDOM_UA_PER_PROXY`` to True to allow switch per proxy
2. set priority of ``RandomUserAgentMiddleware`` to be greater than ``scrapy-proxies``, so that proxy is set before handle UA
.. |GitHub version| image:: https://badge.fury.io/gh/alecxe%2Fscrapy-fake-useragent.svg
:target: http://badge.fury.io/gh/alecxe%2Fscrapy-fake-useragent
.. |Requirements Status| image:: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements.svg?branch=master
:target: https://requires.io/github/alecxe/scrapy-fake-useragent/requirements/?branch=master
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for scrapy-fake-useragent-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8cd95c6274256faeda2fb48511e2f4f1eaf9f7dd6c48992d2cfe2a780e2d5ff |
|
MD5 | 4fef19a59493d9194223804635ad5b5f |
|
BLAKE2b-256 | 7372389d98e183f238b845ecf1f0865bf42f2055ad1481be58adbef1a93660a6 |
Close
Hashes for scrapy_fake_useragent-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cec0677675761d4677b018161926a353a52185752690181d100c12dc5a015e88 |
|
MD5 | 7f127d2e18ade59b0151529a59650a98 |
|
BLAKE2b-256 | 5bb2e658fc92548883709990b72acb6115ad0305881ca6b513382e516ceb1a01 |