import requests
from bs4 import BeautifulSoup
url = "http://www.ahnbsj.org/"
headers = {'User-Agent': 'Mozilla/5.0'}
r1 = requests.get(url, headers=headers)
soup=BeautifulSoup(r1.text, 'lxml')
with open("web.txt", "w", encoding="utf-8") as f:
f.writelines(soup.prettify())
for content in soup.find_all(name='a',class_=["articleid memberoff"]): #同时满足两个条件的find_all的使用
print(content["title"]+content["href"])
用beautifulsoup爬内审协会的练习
最新推荐文章于 2024-06-16 10:55:10 发布