import requests from bs4 import BeautifulSoup url = 'https://so.gushiwen.cn/gushi/tangshi.aspx' r = requests.get(url) r.encoding = "utf8" html = r.text # print(html) print(r.status_code) list = [] soup = BeautifulSoup(html,'html.parser') links = soup.find_all('strong') for link in links: if not link: continue print(link.text) poetrys =soup.find_all('a') for poetry in poetrys: if not poetry: continue print('https://so.gushiwen.cn/'+poetry['href'],poetry.text) 结果: