【发布时间】:2020-12-26 05:54:59
【问题描述】:
import requests
from bs4 import BeautifulSoup as bs
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"}
url = "https://www.proxyscan.io/"
r=requests.get(url,headers=headers)
soup = bs(r.content,"html.parser")
a = soup.findAll(scope="row")
a = str(a).replace("<th scope=\"row\">", "").replace("</th>", "").replace("[","").replace("]","").replace(" ","")
a = a.split(",")
for proxy in a:
print(proxy)
【问题讨论】:
-
请确保您的标题总结了具体问题,例如“如何使用没有类的 BeautySoup 提取标签”,然后总结问题究竟是什么“无法获取端口号”。如果您可以添加一些废弃的数据结构,以便有人可以帮助您而无需实际运行您的代码,这也会很有帮助。请检查此链接以提高问题质量,以便更多人可以帮助您stackoverflow.com/help/how-to-ask
标签: python python-3.x python-2.7 beautifulsoup python-requests