python爬取豆瓣影评,涉及知识点:bs4,requests、time、random

2024-02-17 20:59

本文主要是介绍python爬取豆瓣影评,涉及知识点:bs4,requests、time、random,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

页面源代码:


<!DOCTYPE html>
<html lang="zh-CN" class="ua-windows ua-webkit">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="renderer" content="webkit"><meta name="referrer" content="always"><meta name="google-site-verification" content="ok0wCgT20tBBgo9_zat2iAcimtN4Ftf5ccsh092Xeyw" /><title>豆瓣最受欢迎的影评
</title><meta name="baidu-site-verification" content="cZdR4xxR7RxmM4zE" /><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Expires" content="Sun, 6 Mar 2005 01:00:00 GMT"><meta name="keywords" content="影评,热门影评,最新影评"/><meta name="description" content="豆瓣最受欢迎的影评,发表你的影评"/><link rel="alternate" href="/feed/review/best" type="application/rss+xml" title="RSS"><link href="https://img1.doubanio.com/f/vendors/02814fbb5bee25484516bd0a642af695f7ec5a83/css/douban.css" rel="stylesheet" type="text/css"><link href="https://img1.doubanio.com/f/vendors/ee6598d46af0bc554cecec9bcbf525b9b0582cb0/css/separation/_all.css" rel="stylesheet" type="text/css"><link href="https://img1.doubanio.com/f/zerkalo/4b7b75331a86c9c8275ac6b7306e820fc072e09a/css/init.css" rel="stylesheet" type="text/css"><link rel="stylesheet" href="https://img1.doubanio.com/misc/mixed_static/610438fbda6eb614.css"><style type="text/css"></style><script type="text/javascript">var _head_start = new Date();</script><script type="text/javascript" src="https://img1.doubanio.com/f/vendors/6931d89467c7bd3bb6cd748c05cae22368989aea/js/jquery-1.9.1.min.js"></script><script type="text/javascript" src="https://img1.doubanio.com/f/vendors/aa9559674f2476cdc16f755b3cdc4ebc478db669/js/douban.js"></script><script type="text/javascript" src="https://img1.doubanio.com/f/vendors/e38c65a87555287f5fb7c997e41b908d72ff9731/js/lib/moreurl.js"></script><script type="text/javascript" src="https://img1.doubanio.com/f/vendors/b0d3faaf7a432605add54908e39e17746824d6cc/js/separation/_all.js"></script><script type="text/javascript" src="https://img1.doubanio.com/f/zerkalo/8f98eaec1c9c779076c24b46fe052ee9c2dd52d8/dist/js/base.js"></script><script type="text/javascript"></script><link rel="shortcut icon" href="https://img1.doubanio.com/favicon.ico" type="image/x-icon">
</head><body><script type="text/javascript">var _body_start = new Date();</script><link href="//img3.doubanio.com/dae/accounts/resources/ded47ae/shire/bundle.css" rel="stylesheet" type="text/css"><div id="db-global-nav" class="global-nav"><div class="bd"><div class="top-nav-info"><a href="https://accounts.douban.com/passport/login?source=main" class="nav-login" rel="nofollow">登录/注册</a>
</div><div class="top-nav-doubanapp"><a href="https://www.douban.com/doubanapp/app?channel=top-nav" class="lnk-doubanapp">下载豆瓣客户端</a><div id="doubanapp-tip"><a href="https://www.douban.com/doubanapp/app?channel=qipao" class="tip-link">豆瓣 <span class="version">6.0</span> 全新发布</a><a href="javascript: void 0;" class="tip-close">×</a></div><div id="top-nav-appintro" class="more-items"><p class="appintro-title">豆瓣</p><p class="qrcode">扫码直接下载</p><div class="download"><a href="https://www.douban.com/doubanapp/redirect?channel=top-nav&direct_dl=1&download=iOS">iPhone</a><span>·</span><a href="https://www.douban.com/doubanapp/redirect?channel=top-nav&direct_dl=1&download=Android" class="download-android">Android</a></div></div>
</div><div class="global-nav-items"><ul><li class="on"><a href="https://www.douban.com"  data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-main&quot;,&quot;uid&quot;:&quot;0&quot;}">豆瓣</a></li><li class=""><a href="https://book.douban.com" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-book&quot;,&quot;uid&quot;:&quot;0&quot;}">读书</a></li><li class=""><a href="https://movie.douban.com" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-movie&quot;,&quot;uid&quot;:&quot;0&quot;}">电影</a></li><li class=""><a href="https://music.douban.com" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-music&quot;,&quot;uid&quot;:&quot;0&quot;}">音乐</a></li><li class=""><a href="https://www.douban.com/location" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-location&quot;,&quot;uid&quot;:&quot;0&quot;}">同城</a></li><li class=""><a href="https://www.douban.com/group" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-group&quot;,&quot;uid&quot;:&quot;0&quot;}">小组</a></li><li class=""><a href="https://read.douban.com&#47;?dcs=top-nav&amp;dcm=douban" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-read&quot;,&quot;uid&quot;:&quot;0&quot;}">阅读</a></li><li class=""><a href="https://fm.douban.com&#47;?from_=shire_top_nav" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-fm&quot;,&quot;uid&quot;:&quot;0&quot;}">FM</a></li><li class=""><a href="https://time.douban.com&#47;?dt_time_source=douban-web_top_nav" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-time&quot;,&quot;uid&quot;:&quot;0&quot;}">时间</a></li><li class=""><a href="https://market.douban.com&#47;?utm_campaign=douban_top_nav&amp;utm_source=douban&amp;utm_medium=pc_web" target="_blank" data-moreurl-dict="{&quot;from&quot;:&quot;top-nav-click-market&quot;,&quot;uid&quot;:&quot;0&quot;}">豆品</a></li></ul>
</div></div>
</div>
<script>;window._GLOBAL_NAV = {DOUBAN_URL: "https://www.douban.com",N_NEW_NOTIS: 0,N_NEW_DOUMAIL: 0};
</script><script src="//img3.doubanio.com/dae/accounts/resources/ded47ae/shire/bundle.js" defer="defer"></script><link href="//img3.doubanio.com/dae/accounts/resources/ded47ae/movie/bundle.css" rel="stylesheet" type="text/css"><div id="db-nav-movie" class="nav"><div class="nav-wrap"><div class="nav-primary"><div class="nav-logo"><a href="https:&#47;&#47;movie.douban.com">豆瓣电影</a></div><div class="nav-search"><form action="https:&#47;&#47;search.douban.com&#47;movie/subject_search" method="get"><fieldset><legend>搜索:</legend><label for="inp-query"></label><div class="inp"><input id="inp-query" name="search_text" size="22" maxlength="60" placeholder="搜索电影、电视剧、综艺、影人" value=""></div><div class="inp-btn"><input type="submit" value="搜索"></div><input type="hidden" name="cat" value="1002" /></fieldset></form></div></div></div><div class="nav-secondary"><div class="nav-items"><ul><li    ><a href="https://movie.douban.com/cinema/nowplaying/">影讯&购票</a></li><li    ><a href="https://movie.douban.com/explore">选电影</a></li><li    ><a href="https://movie.douban.com/tv/">电视剧</a></li><li    ><a href="https://movie.douban.com/chart">排行榜</a></li><li    ><a href="https://movie.douban.com/review/best/">影评</a></li><li    ><a href="https://movie.douban.com/annual/2023/?fullscreen=1&source=navigation">2023年度榜单</a></li><li    ><a href="https://c9.douban.com/app/standbyme-2023/?autorotate=false&fullscreen=true&hidenav=true&monitor_screenshot=true&source=web_navigation"target="_blank">2023年度报告</a></li></ul>
</div><a href="https://movie.douban.com/annual/2023/?fullscreen=1&source=movie_navigation" class="movieannual"></a></div>
</div><script id="suggResult" type="text/x-jquery-tmpl"><li data-link="{{= url}}"><a href="{{= url}}" onclick="moreurl(this, {from:'movie_search_sugg', query:'{{= keyword }}', subject_id:'{{= id}}', i: '{{= index}}', type: '{{= type}}'})"><img src="{{= img}}" width="40" /><p><em>{{= title}}</em>{{if year}}<span>{{= year}}</span>{{/if}}{{if sub_title}}<br /><span>{{= sub_title}}</span>{{/if}}{{if address}}<br /><span>{{= address}}</span>{{/if}}{{if episode}}{{if episode=="unknow"}}<br /><span>集数未知</span>{{else}}<br /><span>共{{= episode}}集</span>{{/if}}{{/if}}</p></a></li></script><script src="//img3.doubanio.com/dae/accounts/resources/ded47ae/movie/bundle.js" defer="defer"></script><div id="wrapper" class="movie-content review-wrapper"><div id="content"><h1>豆瓣最受欢迎的影评</h1&

这篇关于python爬取豆瓣影评,涉及知识点:bs4,requests、time、random的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/718973

相关文章

使用Python和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

一文深入详解Python的secrets模块

《一文深入详解Python的secrets模块》在构建涉及用户身份认证、权限管理、加密通信等系统时,开发者最不能忽视的一个问题就是“安全性”,Python在3.6版本中引入了专门面向安全用途的secr... 目录引言一、背景与动机:为什么需要 secrets 模块?二、secrets 模块的核心功能1. 基

python常见环境管理工具超全解析

《python常见环境管理工具超全解析》在Python开发中,管理多个项目及其依赖项通常是一个挑战,下面:本文主要介绍python常见环境管理工具的相关资料,文中通过代码介绍的非常详细,需要的朋友... 目录1. conda2. pip3. uvuv 工具自动创建和管理环境的特点4. setup.py5.

Python常用命令提示符使用方法详解

《Python常用命令提示符使用方法详解》在学习python的过程中,我们需要用到命令提示符(CMD)进行环境的配置,:本文主要介绍Python常用命令提示符使用方法的相关资料,文中通过代码介绍的... 目录一、python环境基础命令【Windows】1、检查Python是否安装2、 查看Python的安

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

Python虚拟环境与Conda使用指南分享

《Python虚拟环境与Conda使用指南分享》:本文主要介绍Python虚拟环境与Conda使用指南,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、python 虚拟环境概述1.1 什么是虚拟环境1.2 为什么需要虚拟环境二、Python 内置的虚拟环境工具

Python实例题之pygame开发打飞机游戏实例代码

《Python实例题之pygame开发打飞机游戏实例代码》对于python的学习者,能够写出一个飞机大战的程序代码,是不是感觉到非常的开心,:本文主要介绍Python实例题之pygame开发打飞机... 目录题目pygame-aircraft-game使用 Pygame 开发的打飞机游戏脚本代码解释初始化部

Python pip下载包及所有依赖到指定文件夹的步骤说明

《Pythonpip下载包及所有依赖到指定文件夹的步骤说明》为了方便开发和部署,我们常常需要将Python项目所依赖的第三方包导出到本地文件夹中,:本文主要介绍Pythonpip下载包及所有依... 目录步骤说明命令格式示例参数说明离线安装方法注意事项总结要使用pip下载包及其所有依赖到指定文件夹,请按照以