You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import requests
from bs4 import BeautifulSoup
def get_movie():
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
'Host':'movie.douban.com'}
movie_list =[]
for i in range(0,10):
link = 'https://movie.douban.com/top250?start=' + str(i*25)
r = requests.get(link,headers =headers,timeout=8)
print(str(i+1),"内容:",r.status_code)
soup = BeautifulSoup(r.text,"lxml")
div_list = soup.find_all('div',class_='hd')
for each in div_list:
movie = each.a.span.text.strip()
movie_list.append(movie)
return movie_list
print(get_movie())
运行结果:1 内容: 200
['肖申克的救赎']
The text was updated successfully, but these errors were encountered:
import requests
from bs4 import BeautifulSoup
def get_movie():
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
'Host':'movie.douban.com'}
movie_list =[]
for i in range(0,10):
link = 'https://movie.douban.com/top250?start=' + str(i*25)
print(get_movie())
运行结果:1 内容: 200
['肖申克的救赎']
The text was updated successfully, but these errors were encountered: