-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgethttpproxy.py
More file actions
29 lines (22 loc) · 769 Bytes
/
Copy pathgethttpproxy.py
File metadata and controls
29 lines (22 loc) · 769 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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author = owlwang
from __future__ import print_function
import requests
from bs4 import BeautifulSoup
def get_page_content():
r = requests.get('https://free-proxy-list.net/')
if r.status_code != 200 or r.content != '':
return r.text
return None
def main():
html = get_page_content()
soup = BeautifulSoup(html, 'lxml')
table = soup.find('table', id='proxylisttable')
rows = table.find_all('tr')[1:-1] # remove first and last row
s = ('ip', 'port', 'code', 'contry', 'anonymity', 'google', 'https', 'lastchecked')
for tr in rows:
td = tr.find_all('td')
yield {key: td[i].string for i, key in enumerate(s)}
if __name__ == '__main__':
print(list(main()))