import requests
from bs4 import BeautifulSoup
import operator
from lxml import etree
import json
class Spider(object):
def __init__(self):
self.headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36'
}
def getHtml(self,url):
res = requests.get(url,headers=self.headers)
return res.content.decode("utf-8")
def handleInfo(self):
html = self.getHtml("https://movie.douban.com/j/search_subjects?type=movie&tag=%E8%B1%86%E7%93%A3%E9%AB%98%E5%88%86&sort=rank&page_limit=1000&page_start=0")
dic = json.loads(html)
movies = dic["subjects"]
#获取导演和主演信息
print("正在爬取...")
for movie in movies:
movieDetail =json.loads(self.getHtml("https://mo
python3爬取豆瓣电影信息(前500部)
最新推荐文章于 2024-07-24 23:24:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)