python 爬取360看看的电影

时间:2022-05-31 03:05:36
**小编在此爬取的是360看看中的悬疑类电影,喜欢的小伙伴可以收藏。。。。。
当然,也可以给小编提一些改进的意见。。。**

直接上代码:

#coding=utf-8
import requests
from bs4 import BeautifulSoup


url = 'http://www.360kan.com/dianying/list.php?cat=115'
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.3427.400 QQBrowser/9.6.12513.400'}
html =requests.get(url,headers =headers)
soup =BeautifulSoup(html.text,'html.parser')
for href in soup.find_all('li',class_='item'):
for link in href.find_all("a"):
for number in range(1,25):
href = url+'&pageno='+str(number)
html = requests.get(href, headers=headers)
mess = BeautifulSoup(html.text, 'html.parser')
for title in mess.find_all(class_='detail'):
for message in title.find(class_='s1'):
name = message.string
for number in title.find(class_='s2'):
grade = number.string
for act in title.find(class_='star'):
actor = act.string
print "Name: "+ name
print "Grade: "+ grade
print actor
print 'http://www.360kan.com' + link.get('href')
print (" ")

谢谢大家!!!!!