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

This commit is contained in:
2509165020
2026-03-24 10:41:27 +08:00
parent 792d62f71a
commit 86246ac68e

14
爬虫3.24/douban.py.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())