第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我正在嘗試獲取代理和端口 我獲取了代理但無法獲取端口 請幫助我

我正在嘗試獲取代理和端口 我獲取了代理但無法獲取端口 請幫助我

慕桂英546537 2023-07-18 17:44:50
import requestsfrom bs4 import BeautifulSoup as bsheaders = {"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)
查看完整描述

2 回答

?
瀟瀟雨雨

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個贊

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)


查看完整回答
反對 回復(fù) 2023-07-18
?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個贊

您可以使用find_next_siblings()函數(shù)來獲取下一個可用標(biāo)簽。


因此,通過敏銳地觀察解析后的html,我們可以看到端口是代理之后的下一個標(biāo)簽。因此我們可以循環(huán)變量a并找到下一個相鄰的標(biāo)簽。


從 所返回的數(shù)組中獲取第一個元素find_next_siblings()。


大概是這樣的<td>4145</td>。從中清理 html 標(biāo)簽或從中提取字符串td,您應(yīng)該獲得端口號。


for i in a:

    full = i.find_next_siblings()[0]

    port = str(full).replace("<td>","")

    port = str(port).replace("</td>", "")

    print(port)


查看完整回答
反對 回復(fù) 2023-07-18
  • 2 回答
  • 0 關(guān)注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號