CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/公开课/文档/年薪50W+的Python程序员如何写代码/code/Python/opencourse/part01/example10.py
Views: 729
1
import random
2
import time
3
4
import requests
5
from bs4 import BeautifulSoup
6
7
for page in range(10):
8
resp = requests.get(
9
url=f'https://movie.douban.com/top250?start={25 * page}',
10
headers={'User-Agent': 'BaiduSpider'}
11
)
12
soup = BeautifulSoup(resp.text, "lxml")
13
for elem in soup.select('a > span.title:nth-child(1)'):
14
print(elem.text)
15
time.sleep(random.random() * 5)
16
17