xlebpyshek

Proxy parser

Mar 19th, 2021 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4.  
  5. def GetHtml():
  6.     r = requests.get('https://free-proxy-list.net/')
  7.     return r.text
  8.  
  9.  
  10. def GetPageData(html):
  11.     soup = BeautifulSoup(html, 'html.parser')
  12.     line = soup.find('table', class_='table table-striped table-bordered').find('tbody').find_all('tr')
  13.  
  14.     for tr in line:
  15.         td = tr.find_all('td')
  16.         data = {'Proxy': td[0].text,
  17.                 'Port': td[1].text,
  18.                 'Language Code': td[2].text,
  19.                 'Country': td[3].text,
  20.                 'Anonymity': td[4].text,
  21.                 'Https': td[6].text
  22.                 }
  23.  
  24.         print(str(data)[1:-1])
  25.  
  26. GetPageData(GetHtml())
Add Comment
Please, Sign In to add comment