forked from tahaluindo/proxy-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.py
99 lines (76 loc) · 4.06 KB
/
readme.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import json
README = """
# Free HTTP Proxy List 🌍
[![Every 10 Minutes Update](https://github.com/mertguvencli/http-proxy-list/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/mertguvencli/http-proxy-list/actions/workflows/main.yml)
![GitHub](https://img.shields.io/github/license/mertguvencli/http-proxy-list)
![GitHub last commit](https://img.shields.io/github/last-commit/mertguvencli/http-proxy-list)
[![zevtyardt - proxy-list](https://img.shields.io/static/v1?label=zevtyardt&message=proxy-list&color=blue&logo=github)](https://github.com/zevtyardt/proxy-list "Go to GitHub repo")
[![stars - proxy-list](https://img.shields.io/github/stars/zevtyardt/proxy-list?style=social)](https://github.com/zevtyardt/proxy-list)
[![forks - proxy-list](https://img.shields.io/github/forks/zevtyardt/proxy-list?style=social)](https://github.com/zevtyardt/proxy-list)
[![Proxy Updater](https://github.com/zevtyardt/proxy-list/workflows/Proxy%20Updater/badge.svg)](https://github.com/zevtyardt/proxy-list/actions?query=workflow:"Proxy+Updater")
![GitHub repo size](https://img.shields.io/github/repo-size/zevtyardt/proxy-list)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/zevtyardt/proxy-list?logo=commits)](https://github.com/zevtyardt/proxy-list/commits/main)
It is a lightweight project that, every 10 minutes, scrapes lots of free-proxy sites, validates if it works, and serves a clean proxy list.
> Scraper found **{NUMBER_OF_TOTAL_PROXIES}** proxies at the latest update. Usable proxies are below.
## Usage
Click the file format that you want and copy the URL.
|File|Content|Count|
|----|-------|-----|
|[data.txt]({GITHUB_RAW_URL}/proxy-list/data.txt)|`ip_address:port` combined (seperated new line)|{NUMBER_OF_USABLE_PROXIES}|
|[data.json]({GITHUB_RAW_URL}/proxy-list/data.json)|`ip, port`|{NUMBER_OF_USABLE_PROXIES}|
|[data-with-geolocation.json]({GITHUB_RAW_URL}/proxy-list/data-with-geolocation.json)|`ip, port, geolocation`|{NUMBER_OF_USABLE_GEO_PROXIES}|
## Sources
|Source|Found Proxies|Succeed|
|------|-------------|-------|
{SOURCES}
## Sample Proxies With Geolocation Info
|#|Ip|Port|Country|City|Internet Service Provider|
|-|--|----|-------|----|-------------------------|
{PROXY_LIST}
## Contributing
Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.
""" # noqa
GITHUB_RAW_URL = 'https://raw.githubusercontent.com/mertguvencli/http-proxy-list/main' # noqa
def update_readme(metrics: dict):
global README
global GITHUB_RAW_URL
SOURCES_MD = ''
template = '|{}|{}|{}|\n'
for x in metrics['sources']:
source = f'[{x.get("id")}]({x.get("url")})'
found_proxies = x['count']
succeed = x['succeed']
if succeed:
succeed = '✅'
else:
succeed = '🚫'
SOURCES_MD += template.format(source, found_proxies, succeed)
PROXY_LIST_MD = ''
if metrics['counts']['geolocation'] > 0:
template = '|{row_num}|{ip}|{port}|{country}|{city}|{isp}|\n'
with open('proxy-list/data-with-geolocation.json', 'r') as f:
geolocations = json.load(f)
formatted = []
for i, x in enumerate(geolocations, 1):
tmp = dict((k, v) for k, v in dict(x["geolocation"]).items())
tmp["ip"] = x["ip"]
tmp["port"] = x["port"]
tmp['row_num'] = i
formatted.append(tmp)
if i == 20:
break
for x in formatted:
PROXY_LIST_MD += template.format(**x)
else:
PROXY_LIST_MD = '**Something went wrong... Check the actions logs.**'
data = {
'SOURCES': SOURCES_MD,
'PROXY_LIST': PROXY_LIST_MD,
'GITHUB_RAW_URL': GITHUB_RAW_URL,
'NUMBER_OF_TOTAL_PROXIES': str(metrics['counts']['found']),
'NUMBER_OF_USABLE_PROXIES': str(metrics['counts']['usable']),
'NUMBER_OF_USABLE_GEO_PROXIES': str(metrics['counts']['geolocation']),
}
with open('README.md', 'w') as f:
f.write(README.format(**data))