How can I get href in this a tag?

69 views Asked by At

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'))
1

There are 1 answers

0
Alexandru Tudorie On

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