diff --git a/爬虫douban.py0324/douban.py b/爬虫douban.py0324/douban.py new file mode 100644 index 0000000..c699b82 --- /dev/null +++ b/爬虫douban.py0324/douban.py @@ -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()) \ No newline at end of file