# -*- codeing = utf-8 -*-
# @Time: 2021/12/27 14:30
# @Author: 买欣怡
# @File: 7. spider-豆瓣.py
# @Software: PyCharm
from bs4 import BeautifulSoup
import re
import urllib.request, urllib.response
import xlwt
# 影片链接
findLink = re.compile(r'<a href="(.*?)">') # 获取影片链接规则
# 影片图片
findImg = re.compile(r'<img.* src="(.*?)"', re.S) # re.S 忽略换行符
# 影片名字
findName = re.compile(r'<span class="title">(.*?)</span>', re.S) # re.S 忽略换行符
# 影片评分
findRating = re.compile(r'<span class="rating_num" property="v:average">(.*)</span>')
# 影片评价人数
findJudge = re.compile(r'<span>(\d*)人评价</span>')
#找到概况
findInq = re.compile(r'<span class="inq">(.*)</span>')
# 找到影片的相关内容
findBd = re.compile(r'<p class="">(.*?)</p>', re.S)
def main():
baseurl =
Python爬取豆瓣Top250电影排名
于 2022-01-26 10:13:40 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)