0
我要趕在這個頁面的主題的各個環節:https://www.inforge.net/xi/forums/liste-proxy.1118/創建一個腳本來捕獲與Python網頁上的鏈接3
我試圖用這個腳本:
import urllib.request
from bs4 import BeautifulSoup
url = (urllib.request.urlopen("https://www.inforge.net/xi/forums/liste-proxy.1118/"))
soup = BeautifulSoup(url, "lxml")
for link in soup.find_all('a'):
print(link.get('href'))
但它會打印頁面的所有鏈接,而不僅僅是我想要的主題鏈接。你能建議我做到這一點嗎?我還是個新手,最近我開始學習python。
感謝的答案,但如果我按照你的方法,我打印(湯),它給了我頁面的來源,而不是主題的鏈接:\ – Sperly1987
這會爲您提供標記對象。要將url作爲字符串,請在soup.find_all('a',{'class':'PreviewTooltip'})'' –
'中使用'[tag.get('href')作爲標記。現在我得到了我想要的鏈接,但它們在html代碼中。 '[DICHVUSOCKS.US] 23h10 PM UPDATE 24/24- Good Socks'但它是一個很好的一步! :) – Sperly1987