网络数据采集(爬虫基础)

This commit is contained in:
2509165015
2026-03-24 11:29:56 +08:00
parent d3d4aff15d
commit 039058414c

14
260324/douban.py Normal file
View File

@@ -0,0 +1,14 @@
import requests
from bs4 import BeautifulSoup
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'
}
url = 'https://www.douban.com/doulist/3936288/'
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
titles = soup.select('.title a')
for t in titles:
print(t.text.strip())