I'm trying to parse list of proxies from a webpage. The script that I've written can fetch the ips from that site. However, the port appears to be dynamic and the script can't grab them. I suppose there is any way out there to grab the port as well using requests module as I'm not interested to use any browser simulator.
import requests
from bs4 import BeautifulSoup
link = "https://premproxy.com/list/"
with requests.Session() as s:
s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36'
res = s.get(link)
soup = BeautifulSoup(res.text,"lxml")
for item in soup.select("table#proxylistt > tbody > tr.anon"):
proxy = item.select_one("td[data-label^='IP:port']").text
print(proxy)
Current output are like:
52.194.230.130:
37.120.192.154:
203.202.245.58:
190.211.105.86:
Expected output:
52.194.230.130:8080
37.120.192.154:8080
203.202.245.58:80
190.211.105.86:55443
How can I scrape ports from that site using requests?