网络数据采集(爬虫基础)
This commit is contained in:
14
爬虫3.24/douban.py.py
Normal file
14
爬虫3.24/douban.py.py
Normal 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())
|
||||
Reference in New Issue
Block a user