Skip to content

Instantly share code, notes, and snippets.

@KnockOutEZ
Last active September 25, 2024 05:56
Show Gist options
  • Save KnockOutEZ/d64c57c45fd870675ae5d6fee63e5808 to your computer and use it in GitHub Desktop.
Save KnockOutEZ/d64c57c45fd870675ae5d6fee63e5808 to your computer and use it in GitHub Desktop.
Free Proxy Generator
package proxies
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
type ProxyStruct struct {
IP string `json:"ip"`
AnonymityLevel string `json:"anonymityLevel"`
ASN string `json:"asn"`
City string `json:"city"`
Country string `json:"country"`
CreatedAt string `json:"created_at"`
Google bool `json:"google"`
ISP string `json:"isp"`
LastChecked int64 `json:"lastChecked"`
Latency float64 `json:"latency"`
Org string `json:"org"`
Port string `json:"port"`
Protocols []string `json:"protocols"`
Region interface{} `json:"region"`
ResponseTime int `json:"responseTime"`
Speed int `json:"speed"`
UpdatedAt string `json:"updated_at"`
WorkingPercent interface{} `json:"workingPercent"`
UpTime float64 `json:"upTime"`
UpTimeSuccessCount int `json:"upTimeSuccessCount"`
UpTimeTryCount int `json:"upTimeTryCount"`
}
type ProxyResponse struct {
Data []ProxyStruct `json:"data"`
}
func GenerateProxyList() {
// Delete the file if it exists
if _, err := os.Stat("proxies_list.json"); err == nil {
err := os.Remove("proxies_list.json")
if err != nil {
fmt.Println("Error deleting existing file:", err)
return
}
}
// Fetch proxies from proxylist.geonode.com
resp, err := http.Get("https://proxylist.geonode.com/api/proxy-list?filterUpTime=80&filterLastChecked=20&speed=fast&limit=500&page=1&sort_by=lastChecked&sort_type=desc")
if err != nil {
fmt.Println("Error fetching proxies:", err)
return
}
defer resp.Body.Close()
// Read response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
// Parse JSON response
var proxyResponse ProxyResponse
if err := json.Unmarshal(body, &proxyResponse); err != nil {
fmt.Println("Error parsing JSON:", err)
return
}
// Marshal proxies to JSON
jsonData, err := json.Marshal(proxyResponse.Data)
if err != nil {
fmt.Println("Error marshaling JSON:", err)
return
}
// Write JSON data to file
err = os.WriteFile("proxies_list.json", jsonData, 0644)
if err != nil {
fmt.Println("Error writing JSON to file:", err)
return
}
fmt.Println("Proxies saved to proxies_list.json")
}
func ReadProxyList() []ProxyStruct {
// Read the JSON data from proxies_list.json
jsonFile, err := os.Open("proxies_list.json")
if err != nil {
fmt.Printf("could not open JSON file: %v", err)
}
defer jsonFile.Close()
var proxies []ProxyStruct
err = json.NewDecoder(jsonFile).Decode(&proxies)
if err != nil {
fmt.Printf("could not unmarshal JSON: %v", err)
}
return proxies
}
import requests, re
from bs4 import BeautifulSoup
regex = r"[0-9]+(?:\.[0-9]+){3}:[0-9]+"
c = requests.get("https://spys.me/proxy.txt")
test_str = c.text
a = re.finditer(regex, test_str, re.MULTILINE)
with open("proxies_list.txt", 'w') as file:
for i in a:
print(i.group(),file=file)
d = requests.get("https://free-proxy-list.net/")
soup = BeautifulSoup(d.content, 'html.parser')
td_elements = soup.select('.fpl-list .table tbody tr td')
ips = []
ports = []
for j in range(0, len(td_elements), 8):
ips.append(td_elements[j].text.strip())
ports.append(td_elements[j + 1].text.strip())
with open("proxies_list.txt", "a") as myfile:
for ip, port in zip(ips, ports):
proxy = f"{ip}:{port}"
print(proxy, file=myfile)
@KnockOutEZ
Copy link
Author

@KnockOutEZ iotirto8

What?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment