-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathproxies.py
More file actions
32 lines (23 loc) · 787 Bytes
/
proxies.py
File metadata and controls
32 lines (23 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3'
import json
import requests
import random
from lxml import html
from selenium import webdriver
def fetch_proxies() -> list:
'''fetch list of proxies from url'''
url = 'https://www.sslproxies.org/'
page = requests.get(url)
tree = html.fromstring(page.content)
elements = tree.xpath('//*[@id="proxylisttable"]/tbody')[0]
proxies = []
keys = ['ip', 'port', 'code', 'country', 'anonymity', 'google', 'https', 'last_checked']
for row in elements.getchildren():
values = [col.text for col in row.getchildren()]
proxies.append(dict(zip(keys, values)))
return proxies
def get_my_ip() -> str:
url = 'https://api.ipify.org'
reply = requests.get(url)
assert reply.status_code == 200
return reply.text