Proxy scraper for further use
Project description
Free-proxy
Get free working proxy from https://www.sslproxies.org/, https://www.us-proxy.org/, https://free-proxy-list.net/uk-proxy.html and https://free-proxy-list.net and use it in your script
FreeProxy class scrapes proxies from https://www.sslproxies.org/, https://www.us-proxy.org/, https://free-proxy-list.net/uk-proxy.html and https://free-proxy-list.net and checks if proxy is working. There is possibility to filter proxies by country and acceptable timeout. You can also randomize list of proxies from where script would get first working proxy.
You can use it in sending request through custom proxy, with selenium or wherever you want.
Returns proxy as string:
'http://113.160.218.14:8888'
Requirements
- Python3
- Request library
- Lxml library
Installation
pip install free-proxy
Usage with examples
First import Free Proxy that way:
from fp.fp import FreeProxy
Options
| Parameter | Type | Example | Default value |
|---|---|---|---|
| country_id | list | ['US', 'BR'] | None |
| timeout | float > 0 | 0.1 | 0.5 |
| rand | bool | True | False |
| anonym | bool | True | False |
| elite | bool | True | False |
| bool,None | False | None | |
| https | bool | True | False |
- No parameters Get first working proxy from https://www.sslproxies.org/. When no proxy is working, repeat once again from https://free-proxy-list.net
proxy = FreeProxy().get()
country_idparameter Get first working proxy from specified list of countries (from https://www.sslproxies.org/). If there is no valid proxy from specified list check all countries from https://free-proxy-list.net.
proxy = FreeProxy(country_id=['US', 'BR']).get()
country_idfor US and GB You can set country_id to US and GB to get proxy from United States or United Kingdom. In that case proxies will be scrapped from https://www.us-proxy.org/ (US) or https://free-proxy-list.net/uk-proxy.html (GB) page. If there is no valid proxy from specified list check all countries
proxy = FreeProxy(country_id=['US']).get()
proxy = FreeProxy(country_id=['GB']).get()
timeoutparameter Timeout is parameter for checking if proxy is valid. If test site doesn't respond in specified time script marks this proxy as invalid. Defaulttimeout=0.5. You can change it by defining specified timeout eg.timeout=1.
proxy = FreeProxy(timeout=1).get()
randparameter Shuffles proxy list from https://www.sslproxies.org/. Defaultrand=Falseand searches for working proxy from newest to oldest (as they are listed in https://www.sslproxies.org/).
proxy = FreeProxy(rand=True).get()
anonymparameter Return only those proxies that are marked as anonymous. Defaults toanonym=False
proxy = FreeProxy(anonym=True).get()
eliteparameter Return only those proxies that are marked as 'elite proxy'. Defaults toelite=False.
proxy = FreeProxy(elite=True).get()
Note that elite proxies are anonymous at the same time, thus anonym=True automatically when elite=True.
googleparameter IfTrueit returns only those proxies that are marked as goggle, ifFalse- as no google. Defaults togoogle=Nonethat returns all proxies.
proxy = FreeProxy(google=True).get()
-
httpsparameter If true it returns only those proxies that are marked as HTTPS. Defaults tohttps=False- i.e. HTTP proxy (for HTTP websites).Note that HTTPS proxy is for both HTTP and HTTPS websites.
proxy = FreeProxy(https=True).get()
You can combine parameters:
proxy = FreeProxy(country_id=['US', 'BR'], timeout=0.3, rand=True).get()
If there are no working proxies with provided parameters script raises FreeProxyException with There are no working proxies at this time. message.
CHANGELOG
[1.1.0] - 2022-11-12
- Added new website to get proxies from https://free-proxy-list.net
- Added new website to get proxies from https://free-proxy-list.net/uk-proxy.html
- Added new website to get proxies from https://www.us-proxy.org/
- Change lxml version to 4.9.1
[1.0.6] - 2022-01-23
- Added
googleparameter - Added
httpsparameter
[1.0.5] - 2022-01-07
- Added
eliteparameter - Add exception class and raise exception instead of system exit
- Change lxml version to 4.6.5
[1.0.4] - 2021-11-13
- Fix proxy list default length
[1.0.3] - 2021-08-18
- Change XPatch due to SSL proxies page update
- Change lxml version
[1.0.2] - 2020-09-03
- Added
anonymparameter
[1.0.1] - 2020-03-19
- Fix typos in readme
- Fix urrlib3 exception
urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme None, - Fix imports
[1.0.0] - 2019-02-04
- Initial release
License
MIT
Free Software!
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
File details
Details for the file free_proxy-1.1.0.tar.gz.
File metadata
- Download URL: free_proxy-1.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aedf9a7ae235972d03443f1bd935445d4c1f014a587d967c3f5ab86bf74c5286
|
|
| MD5 |
c4b70f2df8f6e86dbe3106029771969c
|
|
| BLAKE2b-256 |
f0ee191c5a5b5089d580b7284a764e824d7dfbe9204b39fa5e059dc3bde24fda
|