Lihtne avalik puhverserveri parser Pythonis, kasutades Google'i otsingut. Me hakkame kasutama googlesearch-python
raamatukogu Google'i otsingute tegemiseks ja BeautifulSoup
HTML-i sõelumiseks.
Esiteks veenduge, et teil on installitud vajalikud teegid:
pip install beautifulsoup4 google
Nüüd loome puhverserveri parseri:
from googlesearch import search
from bs4 import BeautifulSoup
import requests
def fetch_proxies():
proxies = []
# Perform a Google search for public proxy lists
query = "public proxy list"
for url in search(query, num=5, stop=5, pause=2):
# Fetch the HTML content of the search result
try:
response = requests.get(url, timeout=10)
if response.status_code == 200:
html_content = response.text
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html_content, 'html.parser')
# Find proxy IP addresses and ports
for row in soup.find_all('tr'):
cols = row.find_all('td')
if len(cols) >= 2:
proxy = cols[0].text.strip() + ':' + cols[1].text.strip()
proxies.append(proxy)
except Exception as e:
print(f"Error fetching proxies from {url}: {e}")
return proxies
if __name__ == "__main__":
proxies = fetch_proxies()
for proxy in proxies:
print(proxy)
See skript teostab Google'i otsingu avalike puhverserveri loendite jaoks, sõelub otsingutulemuste HTML-i ja eraldab puhverserveri IP-aadressid ja pordid. Pange tähele, et selle meetodi abil saadud puhverserveri kvaliteet ja usaldusväärsus võivad erineda. Lisaks kasutage alati puhverservereid vastutustundlikult ja järgige nende veebisaitide teenusetingimusi, millele nende kaudu juurde pääsete.
Kommentaarid (0)
Siin pole veel kommentaare, võite olla esimene!