Get Proxy List by Using Python
Published: 2020-07-04 14:07:45

In this tutorial, We'll learn how to get a fresh proxy by using Proxyscrape library.

<h2>1. Proxyscrape Installation</h2>
```python
pip install proxyscrape
```

##2. getting united states proxy
In the first example, we'll get a proxy of united states

```python
import proxyscrape
collector = proxyscrape.create_collector('my-collector', 'http')  # Create a collector for http resources
proxy = collector.get_proxy({'country': 'united states'})  # Retrieve a united states proxy
print(proxy) # print the proxy
```
So first we have imported the library, then created our collector, finally, chose the country, now let's see the output.

```python
Proxy(host='103.105.49.53', port='80', code='us', country='united states', anonymous=True, type='http', source='free-proxy-list')
```
Print the host and the port:
```python
print(f"{proxy.host}:{proxy.port}")
#output
103.105.49.53:80
```

##3. Getting proxies list

In this part, we'll get a France list of proxies

syntax:
```python
collector.get_proxies()
```

Example
```python
proxy = collector.get_proxies({'country': 'france'})  
print(proxy)
```

Output

```python
[Proxy(host='51.158.123.35', port='8811', code='fr', country='france', anonymous=True, type='http', source='anonymous-proxy'), 
Proxy(host='195.154.233.187', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='195.154.51.252', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='195.154.52.142', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='212.83.140.218', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='51.158.123.250', port='8811', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='195.154.47.113', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='51.158.98.121', port='8811', code='fr', country='france', anonymous=True, type='https', source='anonymous-proxy'), 
Proxy(host='159.8.114.34', port='8123', code='fr', country='france', anonymous=True, type='http', source='free-proxy-list'), 
Proxy(host='195.154.56.105', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='195.154.52.142', port='3838', code='fr', country='france', anonymous=True, type='https', source='anonymous-proxy'), 
Proxy(host='195.154.56.105', port='3838', code='fr', country='france', anonymous=True, type='https', source='anonymous-proxy'), 
Proxy(host='51.158.98.121', port='8811', code='fr', country='france', anonymous=True, type='http', source='free-proxy-list'), 
Proxy(host='51.158.123.250', port='8811', code='fr', country='france', anonymous=True, type='https', source='anonymous-proxy'), 
Proxy(host='51.158.119.88', port='8811', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='163.172.120.204', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='46.218.155.194', port='3128', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='51.15.156.144', port='3838', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list'), 
Proxy(host='51.158.165.18', port='8811', code='fr', country='france', anonymous=True, type='https', source='free-proxy-list')]
```


References:
[proxyscrape Library ](https://pypi.org/project/proxyscrape/)

[PyTutorial](https://pytutorial.com)