I want to get the href (https://www.dcard.tw/forum/popular) from https://www.dcard.tw/
this href is under <a href="/forum/popular">
my code:
from bs4 import BeautifulSoup
import requests
url = "https://www.dcard.tw/"
soup = BeautifulSoup(requests.get(url).text,'lxml')
for link in soup.find_all('a'):
print(link.get('href'))
You can try the examples from this thread, they got some successful options.
How can I get href links from HTML using Python?
Regards, Alex