Google 검색을 사용하는 Python의 간단한 공개 프록시 파서입니다. 우리는 googlesearch-python
Google 검색을 수행하는 라이브러리 BeautifulSoup
HTML 구문 분석을 위해.
먼저, 필요한 라이브러리가 설치되어 있는지 확인하세요.
pip install beautifulsoup4 google
이제 프록시 파서를 만들어 보겠습니다.
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)
이 스크립트는 공개 프록시 목록에 대한 Google 검색을 수행하고, 검색 결과의 HTML을 구문 분석하고, 프록시의 IP 주소와 포트를 추출합니다. 이 방법을 사용하여 얻은 프록시의 품질과 신뢰성은 다를 수 있습니다. 또한 항상 프록시를 책임감 있게 사용하고 프록시를 통해 액세스하는 웹사이트의 서비스 약관을 준수하십시오.
댓글 (0)
여기에는 아직 댓글이 없습니다. 첫 번째 댓글이 되실 수 있습니다!