matheusfelipeog / froxy

Hide your IP with free proxies using Froxy πŸ”„

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyPI - Status PyPI GitHub release (latest by date) License MIT

Froxy logo
Hide your IP with free proxies

Index

The goal

This project aims to provide an interface for filter and using free proxies in your web scraping and web crawler projects with Python and requests module.

How it works?

Froxy uses the API available at Proxy List and runs a filter to obtain only proxies and their information. Then it provides an interface to filter and use the filtered proxies.

Why are you using this API?

  • It free.
  • No query limit.
  • It has a variety of types of proxies.
  • It has an interesting amount of proxies.
  • It is updated daily.

Thank you for maintaining and making this API available @clarketm ❀

Install

install using pip:

$ pip install froxy

then, see the demo or documentation for more information.

Demo

This is a demo use to get proxies with a filter:

from froxy import Froxy

froxy = Froxy()

for proxy in froxy.https(): # Get proxies with protocol https
    print(proxy)

# Output
['125.17.80.226', '8080', ['IN', 'H', 'S', '+']]  
['31.204.180.44', '53281', ['RU', 'H', 'S', '-']] 
['213.108.173.247', '8080', ['RU', 'N', 'S', '-']]
['109.169.151.131', '8080', ['RU', 'N', 'S', '+']]
['149.129.240.8', '8080', ['SG', 'N', 'S', '-']],
[...]

This a demo use with requests module:

import requests

from froxy import Froxy

froxy = Froxy()
ip, port = froxy.http()[0][:2] # Get first proxy (IP and PORT)

proxies = {
    "http": f'{ip}:{port}',
    "https": f'{ip}:{port}'
}

r = requests.get('https://httpbin.org/ip', proxies=proxies)
print(f'Response: {r.json()}')

# Output
Response: {'origin': '103.250.69.233'}

⚠ Warning ⚠

Not all proxies work, so try to use only those that work use try...except as a "filter"

Basic example:

import requests

from froxy import Froxy

froxy = Froxy()

for proxy in froxy.http():
   ip, port = proxy[:2]
   
   proxies = {
       "http": f'{ip}:{port}',
       "https": f'{ip}:{port}'
   }
   
   try:
       r = requests.get('https://httpbin.org/ip', proxies=proxies)
       print(f'Response: {r.json()}')
       
   except Exception:
       print('Fail, next...')
       continue
       
# output
Response: {'origin': '103.250.69.233'}
Fail, next...
Fail, next...
Fail, next...
Fail, next...
Response: {'origin': '212.32.213.170'}
...

Doc

Use help function for more information:

>>> from froxy import Froxy
>>> help(Froxy)

froxy.Froxy

A class for manipulating and filtering proxies.

All public method returns are made up of a list of lists in the following structure:

# Structure
[
    [ip_adress, port, [country_code, anonymity, http_or_https, google_passed]],
    ...
]

# Example:
[
    ['189.6.191.184', '8080', ['BR', 'N', 'S', '+']],
    ...
]

Froxy.country(...)

Filter proxies for country.

See all codes at: ISO 3166-1 alpha-2

Usage:

>>> from froxy import Froxy
>>> froxy = Froxy()
>>> froxy.country('RS', 'US')
# Example output
[
    ['255.255.255.255', '3000', ['RS', 'N', 'S!', '-'], 
    ['254.254.254.254', '8058', ['US', 'N', 'S!', '+'],
    ...
]

Froxy.anonymity(...)

Filter proxies by anonymity level.

Usage:

>>> from froxy import Froxy
>>> froxy = Froxy()
>>> froxy.anonymity('A', 'H')
# Example output
[
    ['255.255.255.255', '3000', ['RS', 'H', 'S!', '-'],
    ['254.254.254.254', '8058', ['US', 'A', 'S!', '+'],
    ...
]

Froxy.http(...)

Filter proxies by http protocol.

Usage:

>>> from froxy import Froxy
>>> froxy = Froxy()
>>> froxy.http()
# Example output
[
    ['255.255.255.255', '3000', ['AA', 'H', '!', '-'], 
    ['254.254.254.254', '8058', ['ZZ', 'A', '', '+'],
    ...
]

Froxy.https(...)

Filter proxies by https protocol.

Usage:

>>> from froxy import Froxy
>>> froxy = Froxy()
>>> froxy.https()
# Example output
[
    ['255.255.255.255', '3000', ['AA', 'H', 'S!', '-'], 
    ['254.254.254.254', '8058', ['ZZ', 'A', 'S', '+'],
    ...
]

Froxy.google(...)

Filter proxies by google passed.

Usage:

>>> from froxy import Froxy
>>> froxy = Froxy()
>>> froxy.google('+')
# Example output
[
    ['255.255.255.255', '3000', ['AA', 'H', 'S!', '+'], 
    ['254.254.254.254', '8058', ['YY', 'N', '', '+'],
    ...
]

Froxy.get(...)

Use multiple proxy filters or get all proxies if the filter arguments are empty.

Usage:

>>> from froxy import Froxy
>>> froxy = Froxy()
>>> froxy.get(
        country=[1, 'US', 'BR'],
        anonymity=[2, 'H'],
        protocol=[2, 'https'],
        google_passed=[1, '+']
    )
# Example output
[
    ['255.255.255.255', '3000', ['US', 'H', 'S!', '+'], 
    ['254.254.254.254', '8058', ['BR', 'A', 'S', '+'],
    ['254.254.254.253', '6000', ['TT', 'H', '', '-'],
    ['254.254.254.252', '4058', ['BR', 'H', '!', '-'],
    ['255.255.255.251', '3000', ['RS', 'H', 'S', '-'], 
    ['254.254.254.250', '7058', ['ZZ', 'H', 'S!', '-'],
    ['254.254.254.250', '7058', ['YY', 'N', '', '+']
]

Use help function for more information or visit repository of API for more details.

Contributions

All contributions are welcome!

Found a problem, want to give a tip? open an issue.

Do you have a solution to the problem? Send me a PR.

Did you like this project? Click on the little star πŸ˜„

License

This project is using the MIT license, see in MIT LICENSE.

For more information on the API used, visit clarketm/proxy-list.

ezoic increase your site revenue

About

Hide your IP with free proxies using Froxy πŸ”„

License:MIT License


Languages

Language:Python 100.0%