一、re模块
1、match方法
import re # match 验证用户输入的内容 ret = re.match('\d+', 'hhoi2342ho12ioh11') print(ret) # None ret = re.match('\d+', '342khjlh324jbk234') print(ret) # <re.Match object; span=(0, 3), match='342'> print(ret.group()) # 342 # match是从开头开始匹配,不符合则返回None
2、split 切割
import re
# 切割 split s1 = 'alex|egon|taibai' print(s1.split('|')) # ['alex', 'egon', 'taibai'] s = 'alex345egon3056taibai' # 不保留切割内容 ret = re.split('\d+', s) print(ret) # ['alex', 'egon', 'taibai'] # 保留切割内容 ret = re.split('(\d+)', s) print(ret) # ['alex', '345', 'egon', '3056', 'taibai']
3、sub 替换
import re # 替换 sub s = 'alex|egon|taibai' print(s.replace('|', '-')) # alex-egon-taibai s1 = 'alex234egon342taibai' # 默认全部替换 ret = re.sub('\d+', '|', s1) print(ret) # alex|egon|taibai # 设置替换次数 ret = re.sub('\d+', '|', s1, 1) print(ret) # alex|egon342taibai # 默认全部替换,并返回一个元祖,元祖的第二个值是替换的次数 ret = re.subn('\d+', '|', s1) print(ret) # ('alex|egon|taibai', 2) # 设置替换次数,并返回一个元祖,元祖的第二个值是替换的次数 ret = re.subn('\d+', '|', s1, 1) print(ret) # ('alex|egon342taibai', 1)
4、compile 编译正则规则
import re # compile 编译正则规则 com = re.compile('\d+') print(com) # re.compile('\\d+') ret = com.search('sdf2g23jkgk21k21') print(ret.group()) # 2 ret = com.findall('sdf2g23jkgk21k21') print(ret) # ['2', '23', '21', '21'] ret = com.finditer('sdf2g23jkgk21k21') for i in ret: print(i.group()) # 2 # 23 # 21 # 21
5、finditer 节省空间的方法
import re # finditer 节省空间的方法 ret = re.finditer('\d+', 'sdf2g23jkgk21k21') print(ret) # <callable_iterator object at 0x00A6AF10> 迭代器 for i in ret: print(i.group()) # 2 # 23 # 21 # 21
6、分组命名、分组约束
在前端中常见的: <h1>函数</h1>
实际上对于前端语言来说,都是把不同样式的字体放在不同的标签中
import re # 分组命名、分组约束 pattern = '<(?P<tag>.*?)>.*?</(?P=tag)>' ret = re.search(pattern, '<h1>函数</h1>') print(ret) # <re.Match object; span=(0, 11), match='<h1>函数</h1>'> if ret: print(ret.group()) # <h1>函数</h1> print(ret.group(1)) # h1 print(ret.group('tag')) # h1 pattern = r'<(.*?)>.*?</\1>' ret = re.search(pattern, '<a>函数</a>') print(ret) # <re.Match object; span=(0, 9), match='<a>函数</a>'> if ret: print(ret.group()) # <a>函数</a> print(ret.group(1)) # a ''' (?:正则表达式) 表示取消优先显示功能 (?P<组名>正则表达式) 表示给这个组取一个名字 (?P=组名) 表示引用之前组的名字,引用部分匹配到的内容必须和之前那个组中的内容一模一样 '''
1 from urllib.request import urlopen 2 3 ret = urlopen('https://movie.douban.com/top250?start=225&filter=') 4 content = ret.read().decode('utf-8') 5 print(content) 6 7 ''' 8 <!DOCTYPE html> 9 <html lang="zh-cmn-Hans" class=""> 10 <head> 11 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 12 <meta name="renderer" content="webkit"> 13 <meta name="referrer" content="always"> 14 <meta name="google-site-verification" content="ok0wCgT20tBBgo9_zat2iAcimtN4Ftf5ccsh092Xeyw" /> 15 <title> 16 豆瓣电影 Top 250 17 </title> 18 19 <meta name="baidu-site-verification" content="cZdR4xxR7RxmM4zE" /> 20 <meta http-equiv="Pragma" content="no-cache"> 21 <meta http-equiv="Expires" content="Sun, 6 Mar 2005 01:00:00 GMT"> 22 23 <link rel="apple-touch-icon" href="https://img3.doubanio.com/f/movie/d59b2715fdea4968a450ee5f6c95c7d7a2030065/pics/movie/apple-touch-icon.png"> 24 <link href="https://img3.doubanio.com/f/shire/bf61b1fa02f564a4a8f809da7c7179b883a56146/css/douban.css" rel="stylesheet" type="text/css"> 25 <link href="https://img3.doubanio.com/f/shire/ae3f5a3e3085968370b1fc63afcecb22d3284848/css/separation/_all.css" rel="stylesheet" type="text/css"> 26 <link href="https://img3.doubanio.com/f/movie/8864d3756094f5272d3c93e30ee2e324665855b0/css/movie/base/init.css" rel="stylesheet"> 27 <script type="text/javascript">var _head_start = new Date();</script> 28 <script type="text/javascript" src="https://img3.doubanio.com/f/movie/0495cb173e298c28593766009c7b0a953246c5b5/js/movie/lib/jquery.js"></script> 29 <script type="text/javascript" src="https://img3.doubanio.com/f/shire/f010949d3f23dd7c972ad7cb40b800bf70723c93/js/douban.js"></script> 30 <script type="text/javascript" src="https://img3.doubanio.com/f/shire/0efdc63b77f895eaf85281fb0e44d435c6239a3f/js/separation/_all.js"></script> 31 32 <link href="https://img3.doubanio.com/f/movie/2c95f768ea74284b900c04c0209b0a44f0a0de52/css/movie/top_movies.css" rel="stylesheet" type="text/css" /> 33 <script type="text/javascript" src="https://img3.doubanio.com/f/shire/77323ae72a612bba8b65f845491513ff3329b1bb/js/do.js" data-cfg-autoload="false"></script> 34 <script type='text/javascript'> 35 Do.ready(function(){ 36 $("#mine-selector input[type='checkbox']").click(function(){ 37 var val = $(this).is(":checked")?$(this).val():""; 38 window.location.href = '/top250?filter=' + val; 39 }) 40 }) 41 </script> 42 43 <style type="text/css"> 44 .site-nav-logo img{margin-bottom:0;} 45 </style> 46 <style type="text/css">img { max-width: 100%; }</style> 47 <script type="text/javascript"></script> 48 <link rel="stylesheet" href="https://img3.doubanio.com/misc/mixed_static/562925b5e3824700.css"> 49 50 <link rel="shortcut icon" href="https://img3.doubanio.com/favicon.ico" type="image/x-icon"> 51 </head> 52 53 <body> 54 55 <script type="text/javascript">var _body_start = new Date();</script> 56 57 58 59 60 61 62 <link href="//img3.doubanio.com/dae/accounts/resources/984c231/shire/bundle.css" rel="stylesheet" type="text/css"> 63 64 65 66 <div id="db-global-nav" class="global-nav"> 67 <div class="bd"> 68 69 <div class="top-nav-info"> 70 <a href="https://www.douban.com/accounts/login?source=movie" class="nav-login" rel="nofollow">登录</a> 71 <a href="https://www.douban.com/accounts/register?source=movie" class="nav-register" rel="nofollow">注册</a> 72 </div> 73 74 75 <div class="top-nav-doubanapp"> 76 <a href="https://www.douban.com/doubanapp/app?channel=top-nav" class="lnk-doubanapp">下载豆瓣客户端</a> 77 <div id="doubanapp-tip"> 78 <a href="https://www.douban.com/doubanapp/app?channel=qipao" class="tip-link">豆瓣 <span class="version">6.0</span> 全新发布</a> 79 <a href="javascript: void 0;" class="tip-close">×</a> 80 </div> 81 <div id="top-nav-appintro" class="more-items"> 82 <p class="appintro-title">豆瓣</p> 83 <p class="qrcode">扫码直接下载</p> 84 <div class="download"> 85 <a href="https://www.douban.com/doubanapp/redirect?channel=top-nav&direct_dl=1&download=iOS">iPhone</a> 86 <span>·</span> 87 <a href="https://www.douban.com/doubanapp/redirect?channel=top-nav&direct_dl=1&download=Android" class="download-android">Android</a> 88 </div> 89 </div> 90 </div> 91 92 93 94 95 <div class="global-nav-items"> 96 <ul> 97 <li class=""> 98 <a href="https://www.douban.com" target="_blank" data-moreurl-dict="{"from":"top-nav-click-main","uid":"0"}">豆瓣</a> 99 </li> 100 <li class=""> 101 <a href="https://book.douban.com" target="_blank" data-moreurl-dict="{"from":"top-nav-click-book","uid":"0"}">读书</a> 102 </li> 103 <li class="on"> 104 <a href="https://movie.douban.com" data-moreurl-dict="{"from":"top-nav-click-movie","uid":"0"}">电影</a> 105 </li> 106 <li class=""> 107 <a href="https://music.douban.com" target="_blank" data-moreurl-dict="{"from":"top-nav-click-music","uid":"0"}">音乐</a> 108 </li> 109 <li class=""> 110 <a href="https://www.douban.com/location" target="_blank" data-moreurl-dict="{"from":"top-nav-click-location","uid":"0"}">同城</a> 111 </li> 112 <li class=""> 113 <a href="https://www.douban.com/group" target="_blank" data-moreurl-dict="{"from":"top-nav-click-group","uid":"0"}">小组</a> 114 </li> 115 <li class=""> 116 <a href="https://read.douban.com/?dcs=top-nav&dcm=douban" target="_blank" data-moreurl-dict="{"from":"top-nav-click-read","uid":"0"}">阅读</a> 117 </li> 118 <li class=""> 119 <a href="https://douban.fm/?from_=shire_top_nav" target="_blank" data-moreurl-dict="{"from":"top-nav-click-fm","uid":"0"}">FM</a> 120 </li> 121 <li class=""> 122 <a href="https://time.douban.com/?dt_time_source=douban-web_top_nav" target="_blank" data-moreurl-dict="{"from":"top-nav-click-time","uid":"0"}">时间</a> 123 </li> 124 <li class=""> 125 <a href="https://market.douban.com/?utm_campaign=douban_top_nav&utm_source=douban&utm_medium=pc_web" target="_blank" data-moreurl-dict="{"from":"top-nav-click-market","uid":"0"}">豆品</a> 126 </li> 127 <li> 128 <a href="#more" class="bn-more"><span>更多</span></a> 129 <div class="more-items"> 130 <table cellpadding="0" cellspacing="0"> 131 <tbody> 132 <tr> 133 <td> 134 <a href="https://ypy.douban.com" target="_blank" data-moreurl-dict="{"from":"top-nav-click-ypy","uid":"0"}">豆瓣摄影</a> 135 </td> 136 </tr> 137 </tbody> 138 </table> 139 </div> 140 </li> 141 </ul> 142 </div> 143 144 </div> 145 </div> 146 <script> 147 ;window._GLOBAL_NAV = { 148 DOUBAN_URL: "https://www.douban.com", 149 N_NEW_NOTIS: 0, 150 N_NEW_DOUMAIL: 0 151 }; 152 </script> 153 154 155 156 <script src="//img3.doubanio.com/dae/accounts/resources/984c231/shire/bundle.js" defer="defer"></script> 157 158 159 160 161 162 163 164 165 <link href="//img3.doubanio.com/dae/accounts/resources/19507ad/movie/bundle.css" rel="stylesheet" type="text/css"> 166 167 168 169 170 <div id="db-nav-movie" class="nav"> 171 <div class="nav-wrap"> 172 <div class="nav-primary"> 173 <div class="nav-logo"> 174 <a href="https://movie.douban.com">豆瓣电影</a> 175 </div> 176 <div class="nav-search"> 177 <form action="https://movie.douban.com/subject_search" method="get"> 178 <fieldset> 179 <legend>搜索:</legend> 180 <label for="inp-query"> 181 </label> 182 <div class="inp"><input id="inp-query" name="search_text" size="22" maxlength="60" placeholder="搜索电影、电视剧、综艺、影人" value=""></div> 183 <div class="inp-btn"><input type="submit" value="搜索"></div> 184 <input type="hidden" name="cat" value="1002" /> 185 </fieldset> 186 </form> 187 </div> 188 </div> 189 </div> 190 <div class="nav-secondary"> 191 192 193 <div class="nav-items"> 194 <ul> 195 <li ><a href="https://movie.douban.com/cinema/nowplaying/" 196 >影讯&购票</a> 197 </li> 198 <li ><a href="https://movie.douban.com/explore" 199 >选电影</a> 200 </li> 201 <li ><a href="https://movie.douban.com/tv/" 202 >电视剧</a> 203 </li> 204 <li ><a href="https://movie.douban.com/chart" 205 >排行榜</a> 206 </li> 207 <li ><a href="https://movie.douban.com/tag/" 208 >分类</a> 209 </li> 210 <li ><a href="https://movie.douban.com/review/best/" 211 >影评</a> 212 </li> 213 <li ><a href="https://movie.douban.com/annual/2017?source=navigation" 214 >2017年度榜单</a> 215 </li> 216 <li ><a href="https://movie.douban.com/standbyme/2017?source=navigation" 217 >2017观影报告</a> 218 </li> 219 </ul> 220 </div> 221 222 </div> 223 </div> 224 225 <script id="suggResult" type="text/x-jquery-tmpl"> 226 <li data-link="{{= url}}"> 227 <a href="{{= url}}" onclick="moreurl(this, {from:'movie_search_sugg', query:'{{= keyword }}', subject_id:'{{= id}}', i: '{{= index}}', type: '{{= type}}'})"> 228 <img src="{{= img}}" width="40" /> 229 <p> 230 <em>{{= title}}</em> 231 {{if year}} 232 <span>{{= year}}</span> 233 {{/if}} 234 {{if sub_title}} 235 <br /><span>{{= sub_title}}</span> 236 {{/if}} 237 {{if address}} 238 <br /><span>{{= address}}</span> 239 {{/if}} 240 {{if episode}} 241 {{if episode=="unknow"}} 242 <br /><span>集数未知</span> 243 {{else}} 244 <br /><span>共{{= episode}}集</span> 245 {{/if}} 246 {{/if}} 247 </p> 248 </a> 249 </li> 250 </script> 251 252 253 254 255 <script src="//img3.doubanio.com/dae/accounts/resources/19507ad/movie/bundle.js" defer="defer"></script> 256 257 258 259 260 261 262 <div id="wrapper"> 263 264 265 266 <div id="content"> 267 268 <h1>豆瓣电影 Top 250</h1> 269 270 <div class="grid-16-8 clearfix"> 271 272 273 <div class="article"> 274 275 276 277 278 279 280 281 282 <div class="opt mod"> 283 <div class="tabs"> 284 285 286 287 </div> 288 <span id="mine-selector"> 289 <input type="checkbox" value="unwatched">我没看过的 290 </span> 291 </div> 292 293 294 295 <ol class="grid_view"> 296 <li> 297 <div class="item"> 298 <div class="pic"> 299 <em class="">226</em> 300 <a href="https://movie.douban.com/subject/1292233/"> 301 <img width="100" alt="发条橙" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p529908155.jpg" class=""> 302 </a> 303 </div> 304 <div class="info"> 305 <div class="hd"> 306 <a href="https://movie.douban.com/subject/1292233/" class=""> 307 <span class="title">发条橙</span> 308 <span class="title"> / A Clockwork Orange</span> 309 <span class="other"> / 发条桔子 / 发条橙子</span> 310 </a> 311 312 313 </div> 314 <div class="bd"> 315 <p class=""> 316 导演: Stanley Kubrick 主演: Malcolm McDowell / Patrick Magee / Michael...<br> 317 1971 / 英国 美国 / 犯罪 剧情 科幻 318 </p> 319 320 321 <div class="star"> 322 <span class="rating45-t"></span> 323 <span class="rating_num" property="v:average">8.5</span> 324 <span property="v:best" content="10.0"></span> 325 <span>202041人评价</span> 326 </div> 327 328 <p class="quote"> 329 <span class="inq">我完全康复了。</span> 330 </p> 331 </div> 332 </div> 333 </div> 334 </li> 335 <li> 336 <div class="item"> 337 <div class="pic"> 338 <em class="">227</em> 339 <a href="https://movie.douban.com/subject/1401118/"> 340 <img width="100" alt="黄金三镖客" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2101693489.jpg" class=""> 341 </a> 342 </div> 343 <div class="info"> 344 <div class="hd"> 345 <a href="https://movie.douban.com/subject/1401118/" class=""> 346 <span class="title">黄金三镖客</span> 347 <span class="title"> / Il buono, il brutto, il cattivo.</span> 348 <span class="other"> / 好·坏·丑 / 独行侠决斗地狱门(港)</span> 349 </a> 350 351 352 <span class="playable">[可播放]</span> 353 </div> 354 <div class="bd"> 355 <p class=""> 356 导演: Sergio Leone 主演: Clint Eastwood / Eli Wallach / Lee Van Cleef<br> 357 1966 / 意大利 西班牙 西德 / 冒险 西部 358 </p> 359 360 361 <div class="star"> 362 <span class="rating45-t"></span> 363 <span class="rating_num" property="v:average">9.1</span> 364 <span property="v:best" content="10.0"></span> 365 <span>57570人评价</span> 366 </div> 367 368 <p class="quote"> 369 <span class="inq">最棒的西部片。</span> 370 </p> 371 </div> 372 </div> 373 </div> 374 </li> 375 <li> 376 <div class="item"> 377 <div class="pic"> 378 <em class="">228</em> 379 <a href="https://movie.douban.com/subject/1292062/"> 380 <img width="100" alt="美国丽人" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p571671715.jpg" class=""> 381 </a> 382 </div> 383 <div class="info"> 384 <div class="hd"> 385 <a href="https://movie.douban.com/subject/1292062/" class=""> 386 <span class="title">美国丽人</span> 387 <span class="title"> / American Beauty</span> 388 <span class="other"> / 美丽有罪(港) / 美国心·玫瑰情(台)</span> 389 </a> 390 391 392 <span class="playable">[可播放]</span> 393 </div> 394 <div class="bd"> 395 <p class=""> 396 导演: 萨姆·门德斯 Sam Mendes 主演: 凯文·史派西 Kevin Spacey / 安妮特...<br> 397 1999 / 美国 / 剧情 爱情 家庭 398 </p> 399 400 401 <div class="star"> 402 <span class="rating45-t"></span> 403 <span class="rating_num" property="v:average">8.5</span> 404 <span property="v:best" content="10.0"></span> 405 <span>202029人评价</span> 406 </div> 407 408 <p class="quote"> 409 <span class="inq">每个人的内心都是深不可测的大海。 </span> 410 </p> 411 </div> 412 </div> 413 </div> 414 </li> 415 <li> 416 <div class="item"> 417 <div class="pic"> 418 <em class="">229</em> 419 <a href="https://movie.douban.com/subject/25807345/"> 420 <img width="100" alt="彗星来的那一夜" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2187896711.jpg" class=""> 421 </a> 422 </div> 423 <div class="info"> 424 <div class="hd"> 425 <a href="https://movie.douban.com/subject/25807345/" class=""> 426 <span class="title">彗星来的那一夜</span> 427 <span class="title"> / Coherence</span> 428 <span class="other"> / 相干性 / 相干效应</span> 429 </a> 430 431 432 <span class="playable">[可播放]</span> 433 </div> 434 <div class="bd"> 435 <p class=""> 436 导演: 詹姆斯·沃德·布柯特 James Ward Byrkit 主演: 艾米丽·芭尔多尼 Em...<br> 437 2013 / 美国 英国 / 科幻 悬疑 惊悚 438 </p> 439 440 441 <div class="star"> 442 <span class="rating4-t"></span> 443 <span class="rating_num" property="v:average">8.4</span> 444 <span property="v:best" content="10.0"></span> 445 <span>207481人评价</span> 446 </div> 447 448 <p class="quote"> 449 <span class="inq">小成本大魅力。</span> 450 </p> 451 </div> 452 </div> 453 </div> 454 </li> 455 <li> 456 <div class="item"> 457 <div class="pic"> 458 <em class="">230</em> 459 <a href="https://movie.douban.com/subject/1905462/"> 460 <img width="100" alt="荒野生存" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p465687407.jpg" class=""> 461 </a> 462 </div> 463 <div class="info"> 464 <div class="hd"> 465 <a href="https://movie.douban.com/subject/1905462/" class=""> 466 <span class="title">荒野生存</span> 467 <span class="title"> / Into the Wild</span> 468 <span class="other"> / 浪荡天涯(港) / 阿拉斯加之死(台)</span> 469 </a> 470 471 472 <span class="playable">[可播放]</span> 473 </div> 474 <div class="bd"> 475 <p class=""> 476 导演: 西恩·潘 Sean Penn 主演: 埃米尔·赫斯基 Emile Hirsch / 马西娅·...<br> 477 2007 / 美国 / 冒险 传记 剧情 478 </p> 479 480 481 <div class="star"> 482 <span class="rating45-t"></span> 483 <span class="rating_num" property="v:average">8.6</span> 484 <span property="v:best" content="10.0"></span> 485 <span>138526人评价</span> 486 </div> 487 488 <p class="quote"> 489 <span class="inq">出门必备:本草纲目。</span> 490 </p> 491 </div> 492 </div> 493 </div> 494 </li> 495 <li> 496 <div class="item"> 497 <div class="pic"> 498 <em class="">231</em> 499 <a href="https://movie.douban.com/subject/1291853/"> 500 <img width="100" alt="英国病人" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2408623752.jpg" class=""> 501 </a> 502 </div> 503 <div class="info"> 504 <div class="hd"> 505 <a href="https://movie.douban.com/subject/1291853/" class=""> 506 <span class="title">英国病人</span> 507 <span class="title"> / The English Patient</span> 508 <span class="other"> / 英伦情人(台) / 别问我是谁(港)</span> 509 </a> 510 511 512 <span class="playable">[可播放]</span> 513 </div> 514 <div class="bd"> 515 <p class=""> 516 导演: 安东尼·明格拉 Anthony Minghella 主演: 拉尔夫·费因斯 Ralph Fien...<br> 517 1996 / 美国 英国 / 爱情 剧情 战争 518 </p> 519 520 521 <div class="star"> 522 <span class="rating45-t"></span> 523 <span class="rating_num" property="v:average">8.5</span> 524 <span property="v:best" content="10.0"></span> 525 <span>186720人评价</span> 526 </div> 527 528 <p class="quote"> 529 <span class="inq">In memory, love lives forever...</span> 530 </p> 531 </div> 532 </div> 533 </div> 534 </li> 535 <li> 536 <div class="item"> 537 <div class="pic"> 538 <em class="">232</em> 539 <a href="https://movie.douban.com/subject/1292281/"> 540 <img width="100" alt="迁徙的鸟" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2238274168.jpg" class=""> 541 </a> 542 </div> 543 <div class="info"> 544 <div class="hd"> 545 <a href="https://movie.douban.com/subject/1292281/" class=""> 546 <span class="title">迁徙的鸟</span> 547 <span class="title"> / Le peuple migrateur</span> 548 <span class="other"> / 鸟的迁徙 / 鸟与梦飞行</span> 549 </a> 550 551 552 <span class="playable">[可播放]</span> 553 </div> 554 <div class="bd"> 555 <p class=""> 556 导演: 雅克·贝汉 Jacques Perrin / 雅克·克鲁奥德 Jacques Cluzaud 主演:...<br> 557 2001 / 法国 德国 意大利 西班牙 瑞士 / 纪录片 558 </p> 559 560 561 <div class="star"> 562 <span class="rating45-t"></span> 563 <span class="rating_num" property="v:average">9.1</span> 564 <span property="v:best" content="10.0"></span> 565 <span>55075人评价</span> 566 </div> 567 568 <p class="quote"> 569 <span class="inq">最美的飞翔。</span> 570 </p> 571 </div> 572 </div> 573 </div> 574 </li> 575 <li> 576 <div class="item"> 577 <div class="pic"> 578 <em class="">233</em> 579 <a href="https://movie.douban.com/subject/1428175/"> 580 <img width="100" alt="血钻" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1244017073.jpg" class=""> 581 </a> 582 </div> 583 <div class="info"> 584 <div class="hd"> 585 <a href="https://movie.douban.com/subject/1428175/" class=""> 586 <span class="title">血钻</span> 587 <span class="title"> / Blood Diamond</span> 588 <span class="other"> / 血腥钻石 / 滴血钻石</span> 589 </a> 590 591 592 <span class="playable">[可播放]</span> 593 </div> 594 <div class="bd"> 595 <p class=""> 596 导演: 爱德华·兹威克 Edward Zwick 主演: 莱昂纳多·迪卡普里奥 Leonardo ...<br> 597 2006 / 美国 德国 / 剧情 惊悚 冒险 598 </p> 599 600 601 <div class="star"> 602 <span class="rating45-t"></span> 603 <span class="rating_num" property="v:average">8.5</span> 604 <span property="v:best" content="10.0"></span> 605 <span>149126人评价</span> 606 </div> 607 608 <p class="quote"> 609 <span class="inq">每个美丽事物背后都是滴血的现实。</span> 610 </p> 611 </div> 612 </div> 613 </div> 614 </li> 615 <li> 616 <div class="item"> 617 <div class="pic"> 618 <em class="">234</em> 619 <a href="https://movie.douban.com/subject/25954475/"> 620 <img width="100" alt="聚焦" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2263822658.jpg" class=""> 621 </a> 622 </div> 623 <div class="info"> 624 <div class="hd"> 625 <a href="https://movie.douban.com/subject/25954475/" class=""> 626 <span class="title">聚焦</span> 627 <span class="title"> / Spotlight</span> 628 <span class="other"> / 焦点追击(港) / 惊爆焦点(台)</span> 629 </a> 630 631 632 <span class="playable">[可播放]</span> 633 </div> 634 <div class="bd"> 635 <p class=""> 636 导演: 托马斯·麦卡锡 Thomas McCarthy 主演: 马克·鲁弗洛 Mark Ruffalo /...<br> 637 2015 / 美国 / 剧情 传记 638 </p> 639 640 641 <div class="star"> 642 <span class="rating45-t"></span> 643 <span class="rating_num" property="v:average">8.8</span> 644 <span property="v:best" content="10.0"></span> 645 <span>142728人评价</span> 646 </div> 647 648 <p class="quote"> 649 <span class="inq">新闻人的理性求真。</span> 650 </p> 651 </div> 652 </div> 653 </div> 654 </li> 655 <li> 656 <div class="item"> 657 <div class="pic"> 658 <em class="">235</em> 659 <a href="https://movie.douban.com/subject/4023638/"> 660 <img width="100" alt="国王的演讲" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p768879237.jpg" class=""> 661 </a> 662 </div> 663 <div class="info"> 664 <div class="hd"> 665 <a href="https://movie.douban.com/subject/4023638/" class=""> 666 <span class="title">国王的演讲</span> 667 <span class="title"> / The King's Speech</span> 668 <span class="other"> / 皇上无话儿(港) / 王者之声:宣战时刻(台)</span> 669 </a> 670 671 672 <span class="playable">[可播放]</span> 673 </div> 674 <div class="bd"> 675 <p class=""> 676 导演: 汤姆·霍珀 Tom Hooper 主演: 柯林·菲尔斯 Colin Firth / 杰弗里·...<br> 677 2010 / 英国 澳大利亚 美国 / 剧情 传记 历史 678 </p> 679 680 681 <div class="star"> 682 <span class="rating4-t"></span> 683 <span class="rating_num" property="v:average">8.3</span> 684 <span property="v:best" content="10.0"></span> 685 <span>371667人评价</span> 686 </div> 687 688 <p class="quote"> 689 <span class="inq">皇上无话儿。</span> 690 </p> 691 </div> 692 </div> 693 </div> 694 </li> 695 <li> 696 <div class="item"> 697 <div class="pic"> 698 <em class="">236</em> 699 <a href="https://movie.douban.com/subject/1292214/"> 700 <img width="100" alt="非常嫌疑犯" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p470383576.jpg" class=""> 701 </a> 702 </div> 703 <div class="info"> 704 <div class="hd"> 705 <a href="https://movie.douban.com/subject/1292214/" class=""> 706 <span class="title">非常嫌疑犯</span> 707 <span class="title"> / The Usual Suspects</span> 708 <span class="other"> / 刺激惊爆点(台) / 普通嫌疑犯</span> 709 </a> 710 711 712 <span class="playable">[可播放]</span> 713 </div> 714 <div class="bd"> 715 <p class=""> 716 导演: 布莱恩·辛格 Bryan Singer 主演: 史蒂芬·鲍德温 Stephen Baldwin /...<br> 717 1995 / 德国 美国 / 剧情 犯罪 悬疑 惊悚 718 </p> 719 720 721 <div class="star"> 722 <span class="rating45-t"></span> 723 <span class="rating_num" property="v:average">8.6</span> 724 <span property="v:best" content="10.0"></span> 725 <span>128198人评价</span> 726 </div> 727 728 <p class="quote"> 729 <span class="inq">我不信仰上帝,但我敬畏上帝。</span> 730 </p> 731 </div> 732 </div> 733 </div> 734 </li> 735 <li> 736 <div class="item"> 737 <div class="pic"> 738 <em class="">237</em> 739 <a href="https://movie.douban.com/subject/1307793/"> 740 <img width="100" alt="燕尾蝶" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p532195562.jpg" class=""> 741 </a> 742 </div> 743 <div class="info"> 744 <div class="hd"> 745 <a href="https://movie.douban.com/subject/1307793/" class=""> 746 <span class="title">燕尾蝶</span> 747 <span class="title"> / スワロウテイル</span> 748 <span class="other"> / Swallowtail Butterfly / Suwarôteiru</span> 749 </a> 750 751 752 </div> 753 <div class="bd"> 754 <p class=""> 755 导演: 岩井俊二 Shunji Iwai 主演: 恰拉 Chara / 伊藤步 Ayumi Ito / 三上...<br> 756 1996 / 日本 / 犯罪 剧情 757 </p> 758 759 760 <div class="star"> 761 <span class="rating45-t"></span> 762 <span class="rating_num" property="v:average">8.6</span> 763 <span property="v:best" content="10.0"></span> 764 <span>113716人评价</span> 765 </div> 766 767 <p class="quote"> 768 <span class="inq">现实与童话交相辉映的旅程。</span> 769 </p> 770 </div> 771 </div> 772 </div> 773 </li> 774 <li> 775 <div class="item"> 776 <div class="pic"> 777 <em class="">238</em> 778 <a href="https://movie.douban.com/subject/3217169/"> 779 <img width="100" alt="勇士" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1145536386.jpg" class=""> 780 </a> 781 </div> 782 <div class="info"> 783 <div class="hd"> 784 <a href="https://movie.douban.com/subject/3217169/" class=""> 785 <span class="title">勇士</span> 786 <span class="title"> / Warrior</span> 787 <span class="other"> / 勇者无敌(台) / 钢铁斗士(港)</span> 788 </a> 789 790 791 <span class="playable">[可播放]</span> 792 </div> 793 <div class="bd"> 794 <p class=""> 795 导演: 加文·欧康诺 Gavin O'Connor 主演: 汤姆·哈迪 Tom Hardy / 乔尔·...<br> 796 2011 / 美国 / 剧情 运动 家庭 797 </p> 798 799 800 <div class="star"> 801 <span class="rating45-t"></span> 802 <span class="rating_num" property="v:average">8.9</span> 803 <span property="v:best" content="10.0"></span> 804 <span>94355人评价</span> 805 </div> 806 807 <p class="quote"> 808 <span class="inq">热血沸腾,相当完美的娱乐拳击大餐。</span> 809 </p> 810 </div> 811 </div> 812 </div> 813 </li> 814 <li> 815 <div class="item"> 816 <div class="pic"> 817 <em class="">239</em> 818 <a href="https://movie.douban.com/subject/1291824/"> 819 <img width="100" alt="黑鹰坠落" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1910900710.jpg" class=""> 820 </a> 821 </div> 822 <div class="info"> 823 <div class="hd"> 824 <a href="https://movie.douban.com/subject/1291824/" class=""> 825 <span class="title">黑鹰坠落</span> 826 <span class="title"> / Black Hawk Down</span> 827 <span class="other"> / 黑鹰降落 / 黑鹰计划</span> 828 </a> 829 830 831 <span class="playable">[可播放]</span> 832 </div> 833 <div class="bd"> 834 <p class=""> 835 导演: 雷德利·斯科特 Ridley Scott 主演: 乔什·哈奈特 Josh Hartnett / ...<br> 836 2001 / 美国 / 动作 历史 战争 837 </p> 838 839 840 <div class="star"> 841 <span class="rating45-t"></span> 842 <span class="rating_num" property="v:average">8.6</span> 843 <span property="v:best" content="10.0"></span> 844 <span>130601人评价</span> 845 </div> 846 847 <p class="quote"> 848 <span class="inq">还原真实而残酷的战争。</span> 849 </p> 850 </div> 851 </div> 852 </div> 853 </li> 854 <li> 855 <div class="item"> 856 <div class="pic"> 857 <em class="">240</em> 858 <a href="https://movie.douban.com/subject/1292217/"> 859 <img width="100" alt="穆赫兰道" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p792248233.jpg" class=""> 860 </a> 861 </div> 862 <div class="info"> 863 <div class="hd"> 864 <a href="https://movie.douban.com/subject/1292217/" class=""> 865 <span class="title">穆赫兰道</span> 866 <span class="title"> / Mulholland Dr.</span> 867 <span class="other"> / 穆荷兰大道(台) / 失忆大道(港)</span> 868 </a> 869 870 871 </div> 872 <div class="bd"> 873 <p class=""> 874 导演: 大卫·林奇 David Lynch 主演: 娜奥米·沃茨 Naomi Watts / 劳拉·哈...<br> 875 2001 / 法国 美国 / 剧情 悬疑 惊悚 876 </p> 877 878 879 <div class="star"> 880 <span class="rating4-t"></span> 881 <span class="rating_num" property="v:average">8.3</span> 882 <span property="v:best" content="10.0"></span> 883 <span>254945人评价</span> 884 </div> 885 886 <p class="quote"> 887 <span class="inq">大卫·林奇的梦境迷宫。</span> 888 </p> 889 </div> 890 </div> 891 </div> 892 </li> 893 <li> 894 <div class="item"> 895 <div class="pic"> 896 <em class="">241</em> 897 <a href="https://movie.douban.com/subject/1867345/"> 898 <img width="100" alt="遗愿清单" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p708613284.jpg" class=""> 899 </a> 900 </div> 901 <div class="info"> 902 <div class="hd"> 903 <a href="https://movie.douban.com/subject/1867345/" class=""> 904 <span class="title">遗愿清单</span> 905 <span class="title"> / The Bucket List</span> 906 <span class="other"> / 玩转身前事(港) / 一路玩到挂(台)</span> 907 </a> 908 909 910 <span class="playable">[可播放]</span> 911 </div> 912 <div class="bd"> 913 <p class=""> 914 导演: 罗伯·莱纳 Rob Reiner 主演: 杰克·尼科尔森 Jack Nicholson / 摩根...<br> 915 2007 / 美国 / 冒险 喜剧 剧情 916 </p> 917 918 919 <div class="star"> 920 <span class="rating45-t"></span> 921 <span class="rating_num" property="v:average">8.5</span> 922 <span property="v:best" content="10.0"></span> 923 <span>145700人评价</span> 924 </div> 925 926 <p class="quote"> 927 <span class="inq">用剩余不多的时间,去燃烧整个生命。</span> 928 </p> 929 </div> 930 </div> 931 </div> 932 </li> 933 <li> 934 <div class="item"> 935 <div class="pic"> 936 <em class="">242</em> 937 <a href="https://movie.douban.com/subject/4798888/"> 938 <img width="100" alt="叫我第一名" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p628364149.jpg" class=""> 939 </a> 940 </div> 941 <div class="info"> 942 <div class="hd"> 943 <a href="https://movie.douban.com/subject/4798888/" class=""> 944 <span class="title">叫我第一名</span> 945 <span class="title"> / Front of the Class</span> 946 <span class="other"> / 站在教室前 / 讲台前的我</span> 947 </a> 948 949 950 </div> 951 <div class="bd"> 952 <p class=""> 953 导演: 彼得·维纳 Peter Werner 主演: 詹姆斯·沃克 James Wolk / 特里特·...<br> 954 2008 / 美国 / 剧情 传记 955 </p> 956 957 958 <div class="star"> 959 <span class="rating45-t"></span> 960 <span class="rating_num" property="v:average">8.6</span> 961 <span property="v:best" content="10.0"></span> 962 <span>117631人评价</span> 963 </div> 964 965 <p class="quote"> 966 <span class="inq">乐观比一切都有力量。</span> 967 </p> 968 </div> 969 </div> 970 </div> 971 </li> 972 <li> 973 <div class="item"> 974 <div class="pic"> 975 <em class="">243</em> 976 <a href="https://movie.douban.com/subject/5908478/"> 977 <img width="100" alt="我爱你" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p1075591188.jpg" class=""> 978 </a> 979 </div> 980 <div class="info"> 981 <div class="hd"> 982 <a href="https://movie.douban.com/subject/5908478/" class=""> 983 <span class="title">我爱你</span> 984 <span class="title"> / 그대를 사랑합니다</span> 985 <span class="other"> / 爱你 / 爱,是一生相伴(台)</span> 986 </a> 987 988 989 <span class="playable">[可播放]</span> 990 </div> 991 <div class="bd"> 992 <p class=""> 993 导演: 秋昌民 Chang-min Choo 主演: 宋在河 Jae-ho Song / 李顺载 Soon-jae...<br> 994 2011 / 韩国 / 剧情 爱情 995 </p> 996 997 998 <div class="star"> 999 <span class="rating45-t"></span> 1000 <span class="rating_num" property="v:average">9.0</span> 1001 <span property="v:best" content="10.0"></span> 1002 <span>65021人评价</span> 1003 </div> 1004 1005 <p class="quote"> 1006 <span class="inq">你要相信,这世上真的有爱存在,不管在什么年纪 </span> 1007 </p> 1008 </div> 1009 </div> 1010 </div> 1011 </li> 1012 <li> 1013 <div class="item"> 1014 <div class="pic"> 1015 <em class="">244</em> 1016 <a href="https://movie.douban.com/subject/1300741/"> 1017 <img width="100" alt="枪火" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1538646661.jpg" class=""> 1018 </a> 1019 </div> 1020 <div class="info"> 1021 <div class="hd"> 1022 <a href="https://movie.douban.com/subject/1300741/" class=""> 1023 <span class="title">枪火</span> 1024 <span class="title"> / 鎗火</span> 1025 <span class="other"> / The Mission</span> 1026 </a> 1027 1028 1029 </div> 1030 <div class="bd"> 1031 <p class=""> 1032 导演: 杜琪峰 Johnnie To 主演: 吴镇宇 Francis Ng / 任达华 Simon Yam / ...<br> 1033 1999 / 香港 / 剧情 动作 犯罪 1034 </p> 1035 1036 1037 <div class="star"> 1038 <span class="rating45-t"></span> 1039 <span class="rating_num" property="v:average">8.6</span> 1040 <span property="v:best" content="10.0"></span> 1041 <span>109640人评价</span> 1042 </div> 1043 1044 <p class="quote"> 1045 <span class="inq">一群演技精湛的戏骨,奉献出一个精致的黑帮小品,成就杜琪峰群戏的巅峰之作。</span> 1046 </p> 1047 </div> 1048 </div> 1049 </div> 1050 </li> 1051 <li> 1052 <div class="item"> 1053 <div class="pic"> 1054 <em class="">245</em> 1055 <a href="https://movie.douban.com/subject/1298653/"> 1056 <img width="100" alt="荒岛余生" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2207673534.jpg" class=""> 1057 </a> 1058 </div> 1059 <div class="info"> 1060 <div class="hd"> 1061 <a href="https://movie.douban.com/subject/1298653/" class=""> 1062 <span class="title">荒岛余生</span> 1063 <span class="title"> / Cast Away</span> 1064 <span class="other"> / 浩劫重生(台) / 劫后重生(港)</span> 1065 </a> 1066 1067 1068 <span class="playable">[可播放]</span> 1069 </div> 1070 <div class="bd"> 1071 <p class=""> 1072 导演: 罗伯特·泽米吉斯 Robert Zemeckis 主演: 汤姆·汉克斯 Tom Hanks / ...<br> 1073 2000 / 美国 / 冒险 剧情 1074 </p> 1075 1076 1077 <div class="star"> 1078 <span class="rating45-t"></span> 1079 <span class="rating_num" property="v:average">8.5</span> 1080 <span property="v:best" content="10.0"></span> 1081 <span>149701人评价</span> 1082 </div> 1083 1084 <p class="quote"> 1085 <span class="inq">一个人的独角戏。</span> 1086 </p> 1087 </div> 1088 </div> 1089 </div> 1090 </li> 1091 <li> 1092 <div class="item"> 1093 <div class="pic"> 1094 <em class="">246</em> 1095 <a href="https://movie.douban.com/subject/1292226/"> 1096 <img width="100" alt="2001太空漫游" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p792189453.jpg" class=""> 1097 </a> 1098 </div> 1099 <div class="info"> 1100 <div class="hd"> 1101 <a href="https://movie.douban.com/subject/1292226/" class=""> 1102 <span class="title">2001太空漫游</span> 1103 <span class="title"> / 2001: A Space Odyssey</span> 1104 <span class="other"> / 2001:星际漫游 / 2001:太空奥德赛</span> 1105 </a> 1106 1107 1108 <span class="playable">[可播放]</span> 1109 </div> 1110 <div class="bd"> 1111 <p class=""> 1112 导演: 斯坦利·库布里克 Stanley Kubrick 主演: 凯尔·杜拉 Keir Dullea / ...<br> 1113 1968 / 英国 美国 / 科幻 惊悚 冒险 1114 </p> 1115 1116 1117 <div class="star"> 1118 <span class="rating45-t"></span> 1119 <span class="rating_num" property="v:average">8.7</span> 1120 <span property="v:best" content="10.0"></span> 1121 <span>105862人评价</span> 1122 </div> 1123 1124 <p class="quote"> 1125 <span class="inq">现代科幻电影的开山之作,最伟大导演的最伟大影片。</span> 1126 </p> 1127 </div> 1128 </div> 1129 </div> 1130 </li> 1131 <li> 1132 <div class="item"> 1133 <div class="pic"> 1134 <em class="">247</em> 1135 <a href="https://movie.douban.com/subject/1297478/"> 1136 <img width="100" alt="上帝也疯狂" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2173719647.jpg" class=""> 1137 </a> 1138 </div> 1139 <div class="info"> 1140 <div class="hd"> 1141 <a href="https://movie.douban.com/subject/1297478/" class=""> 1142 <span class="title">上帝也疯狂</span> 1143 <span class="title"> / The Gods Must Be Crazy</span> 1144 <span class="other"> / 众神也疯狂 (上) / 上帝一定发疯了 (上)</span> 1145 </a> 1146 1147 1148 </div> 1149 <div class="bd"> 1150 <p class=""> 1151 导演: Jamie Uys 主演: Marius Weyers / Sandra Prinsloo / N!xau<br> 1152 1980 / 博茨瓦纳 南非 / 喜剧 1153 </p> 1154 1155 1156 <div class="star"> 1157 <span class="rating45-t"></span> 1158 <span class="rating_num" property="v:average">8.6</span> 1159 <span property="v:best" content="10.0"></span> 1160 <span>103665人评价</span> 1161 </div> 1162 1163 <p class="quote"> 1164 <span class="inq">纯净原始的笑与感动。</span> 1165 </p> 1166 </div> 1167 </div> 1168 </div> 1169 </li> 1170 <li> 1171 <div class="item"> 1172 <div class="pic"> 1173 <em class="">248</em> 1174 <a href="https://movie.douban.com/subject/1300117/"> 1175 <img width="100" alt="千钧一发" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2195672555.jpg" class=""> 1176 </a> 1177 </div> 1178 <div class="info"> 1179 <div class="hd"> 1180 <a href="https://movie.douban.com/subject/1300117/" class=""> 1181 <span class="title">千钧一发</span> 1182 <span class="title"> / Gattaca</span> 1183 <span class="other"> / 变种异煞 / 自然人</span> 1184 </a> 1185 1186 1187 <span class="playable">[可播放]</span> 1188 </div> 1189 <div class="bd"> 1190 <p class=""> 1191 导演: 安德鲁·尼科尔 Andrew Niccol 主演: 伊桑·霍克 Ethan Hawke / 乌玛...<br> 1192 1997 / 美国 / 剧情 科幻 惊悚 1193 </p> 1194 1195 1196 <div class="star"> 1197 <span class="rating45-t"></span> 1198 <span class="rating_num" property="v:average">8.7</span> 1199 <span property="v:best" content="10.0"></span> 1200 <span>96480人评价</span> 1201 </div> 1202 1203 <p class="quote"> 1204 <span class="inq">一部能引人思考的科幻励志片。</span> 1205 </p> 1206 </div> 1207 </div> 1208 </div> 1209 </li> 1210 <li> 1211 <div class="item"> 1212 <div class="pic"> 1213 <em class="">249</em> 1214 <a href="https://movie.douban.com/subject/1305725/"> 1215 <img width="100" alt="大卫·戈尔的一生" src="https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2186861098.jpg" class=""> 1216 </a> 1217 </div> 1218 <div class="info"> 1219 <div class="hd"> 1220 <a href="https://movie.douban.com/subject/1305725/" class=""> 1221 <span class="title">大卫·戈尔的一生</span> 1222 <span class="title"> / The Life of David Gale</span> 1223 <span class="other"> / 铁案悬谜 / 命悬一线</span> 1224 </a> 1225 1226 1227 <span class="playable">[可播放]</span> 1228 </div> 1229 <div class="bd"> 1230 <p class=""> 1231 导演: Alan Parker 主演: 凯文·史派西 Kevin Spacey / 凯特·温丝莱特 Kat...<br> 1232 2003 / 美国 德国 英国 / 剧情 犯罪 悬疑 1233 </p> 1234 1235 1236 <div class="star"> 1237 <span class="rating45-t"></span> 1238 <span class="rating_num" property="v:average">8.6</span> 1239 <span property="v:best" content="10.0"></span> 1240 <span>105386人评价</span> 1241 </div> 1242 1243 <p class="quote"> 1244 <span class="inq">捍卫*只是信仰,一点不妨碍其行为的残忍。</span> 1245 </p> 1246 </div> 1247 </div> 1248 </div> 1249 </li> 1250 <li> 1251 <div class="item"> 1252 <div class="pic"> 1253 <em class="">250</em> 1254 <a href="https://movie.douban.com/subject/1308575/"> 1255 <img width="100" alt="蓝色大门" src="https://img3.doubanio.com/view/photo/s_ratio_poster/public/p584822570.jpg" class=""> 1256 </a> 1257 </div> 1258 <div class="info"> 1259 <div class="hd"> 1260 <a href="https://movie.douban.com/subject/1308575/" class=""> 1261 <span class="title">蓝色大门</span> 1262 <span class="title"> / 藍色大門</span> 1263 <span class="other"> / 蓝色夏恋 / Blue Gate Crossing</span> 1264 </a> 1265 1266 1267 </div> 1268 <div class="bd"> 1269 <p class=""> 1270 导演: 易智言 Chih-yen Yee 主演: 陈柏霖 Bo-lin Chen / 桂纶镁 Lunmei Kwa...<br> 1271 2002 / * 法国 / 剧情 爱情 同性 1272 </p> 1273 1274 1275 <div class="star"> 1276 <span class="rating4-t"></span> 1277 <span class="rating_num" property="v:average">8.3</span> 1278 <span property="v:best" content="10.0"></span> 1279 <span>289390人评价</span> 1280 </div> 1281 1282 <p class="quote"> 1283 <span class="inq">青春的窃窃私语。 </span> 1284 </p> 1285 </div> 1286 </div> 1287 </div> 1288 </li> 1289 </ol> 1290 1291 1292 1293 1294 1295 1296 1297 <div class="paginator"> 1298 <span class="prev"> 1299 <link rel="prev" href="?start=200&filter="/> 1300 <a href="?start=200&filter=" ><前页</a> 1301 </span> 1302 1303 1304 1305 1306 <a href="?start=0&filter=" >1</a> 1307 1308 1309 <a href="?start=25&filter=" >2</a> 1310 1311 1312 <a href="?start=50&filter=" >3</a> 1313 1314 1315 <a href="?start=75&filter=" >4</a> 1316 1317 1318 <a href="?start=100&filter=" >5</a> 1319 1320 1321 <a href="?start=125&filter=" >6</a> 1322 1323 1324 <a href="?start=150&filter=" >7</a> 1325 1326 1327 <a href="?start=175&filter=" >8</a> 1328 1329 1330 <a href="?start=200&filter=" >9</a> 1331 1332 <span class="thispage">10</span> 1333 <span class="next"> 1334 后页> 1335 </span> 1336 1337 <span class="count">(共250条)</span> 1338 </div> 1339 1340 1341 1342 </div> 1343 <div class="aside"> 1344 1345 <p class="pl"> 1346 豆瓣用户每天都在对“看过”的电影进行“很差”到“力荐”的评价,豆瓣根据每部影片看过的人数以及该影片所得的评价等综合数据,通过算法分析产生豆瓣电影 Top 250。 1347 </p> 1348 1349 <div id="dale_movie_top250_bottom_right"></div> 1350 1351 <!-- douban ad begin --> 1352 1353 1354 1355 1356 1357 1358 <div class="mobile-app-entrance block5 app-movie"> 1359 <a class="entrance-link" href="https://www.douban.com/doubanapp/frodo"> 1360 <div class="entrance-qrcode"> 1361 <img src="https://img3.doubanio.com/f/movie/a02f6ed325fc52e220f299d51e730c422e2bcd16/pics/movie/douban_app_ad/qrcode.png" alt="扫码下载豆瓣 App" width="80" height="80" /> 1362 </div> 1363 <div class="entrance-info"> 1364 <span class="app-icon icon-movie"></span> 1365 <span class="main-title">豆瓣</span> 1366 <span class="sub-title">让好电影来找你</span> 1367 </div> 1368 </a> 1369 </div> 1370 1371 <!-- douban ad end --> 1372 1373 1374 </div> 1375 <div class="extra"> 1376 1377 </div> 1378 </div> 1379 </div> 1380 1381 1382 <div id="footer"> 1383 <div class="footer-extra"></div> 1384 1385 <span id="icp" class="fleft gray-link"> 1386 © 2005-2018 douban.com, all rights reserved 北京豆网科技有限公司 1387 </span> 1388 1389 <a href="https://www.douban.com/hnypt/variformcyst.py" style="display: none;"></a> 1390 1391 <span class="fright"> 1392 <a href="https://www.douban.com/about">关于豆瓣</a> 1393 · <a href="https://www.douban.com/jobs">在豆瓣工作</a> 1394 · <a href="https://www.douban.com/about?topic=contactus">联系我们</a> 1395 · <a href="https://www.douban.com/about?policy=disclaimer">免责声明</a> 1396 1397 · <a href="https://help.douban.com/?app=movie" target="_blank">帮助中心</a> 1398 · <a href="https://www.douban.com/doubanapp/">移动应用</a> 1399 · <a href="https://www.douban.com/partner/">豆瓣广告</a> 1400 </span> 1401 1402 </div> 1403 1404 </div> 1405 <!-- COLLECTED JS --> 1406 1407 1408 <link rel="stylesheet" type="text/css" href="https://img3.doubanio.com/f/shire/8377b9498330a2e6f056d863987cc7a37eb4d486/css/ui/dialog.css" /> 1409 <link rel="stylesheet" type="text/css" href="https://img3.doubanio.com/f/movie/1d829b8605b9e81435b127cbf3d16563aaa51838/css/movie/mod/reg_login_pop.css" /> 1410 <script type="text/javascript" src="https://img3.doubanio.com/f/shire/77323ae72a612bba8b65f845491513ff3329b1bb/js/do.js" data-cfg-autoload="false"></script> 1411 <script type="text/javascript" src="https://img3.doubanio.com/f/shire/4ea3216519a6183c7bcd4f7d1a6d4fd57ce1a244/js/ui/dialog.js"></script> 1412 <script type="text/javascript"> 1413 var HTTPS_DB='https://www.douban.com'; 1414 var account_pop={open:function(o,e){e?referrer="?referrer="+encodeURIComponent(e):referrer="?referrer="+window.location.href;var n="",i="",t=382;"reg"===o?(n="用户注册",i="https://accounts.douban.com/popup/login?source=movie#popup_register",t=480):"login"===o&&(n="用户登录",i="https://accounts.douban.com/popup/login?source=movie");var r=document.location.protocol+"//"+document.location.hostname,a=dui.Dialog({width:478,title:n,height:t,cls:"account_pop",isHideTitle:!0,modal:!0,content:"<iframe scrolling='no' frameborder='0' width='478' height='"+t+"' src='"+i+"' name='"+r+"'></iframe>"},!0),c=a.node;if(c.undelegate(),c.delegate(".dui-dialog-close","click",function(){var o=$("body");o.find("#login_msk").hide(),o.find(".account_pop").remove()}),$(window).width()<478){var u="";"reg"===o?u=HTTPS_DB+"/accounts/register"+referrer:"login"===o&&(u=HTTPS_DB+"/accounts/login"+referrer),window.location.href=u}else a.open();$(window).bind("message",function(o){"https://accounts.douban.com"===o.originalEvent.origin&&(c.find("iframe").css("height",o.originalEvent.data),c.height(o.originalEvent.data),a.update())})}};Douban&&Douban.init_show_login&&(Douban.init_show_login=function(o){var e=$(o);e.click(function(){var o=e.data("ref")||"";return account_pop.open("login",o),!1})}),Do(function(){$("body").delegate(".pop_register","click",function(o){o.preventDefault();var e=$(this).data("ref")||"";return account_pop.open("reg",e),!1}),$("body").delegate(".pop_login","click",function(o){o.preventDefault();var e=$(this).data("ref")||"";return account_pop.open("login",e),!1})}); 1415 </script> 1416 1417 1418 1419 1420 1421 1422 1423 1424 <script type="text/javascript"> 1425 (function (global) { 1426 var newNode = global.document.createElement('script'), 1427 existingNode = global.document.getElementsByTagName('script')[0], 1428 adSource = '//erebor.douban.com/', 1429 userId = '', 1430 browserId = 'byh9sQdgGxs', 1431 criteria = '3:/top250?start=225&filter=', 1432 preview = '', 1433 debug = false, 1434 adSlots = ['dale_movie_top250_bottom_right']; 1435 1436 global.DoubanAdRequest = {src: adSource, uid: userId, bid: browserId, crtr: criteria, prv: preview, debug: debug}; 1437 global.DoubanAdSlots = (global.DoubanAdSlots || []).concat(adSlots); 1438 1439 newNode.setAttribute('type', 'text/javascript'); 1440 newNode.setAttribute('src', 'https://img3.doubanio.com/f/adjs/cdc904d1376a43e44bbf399a0aff51973016cd77/ad.release.js'); 1441 newNode.setAttribute('async', true); 1442 existingNode.parentNode.insertBefore(newNode, existingNode); 1443 })(this); 1444 </script> 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 <script type="text/javascript"> 1468 var _paq = _paq || []; 1469 _paq.push(['trackPageView']); 1470 _paq.push(['enableLinkTracking']); 1471 (function() { 1472 var p=(('https:' == document.location.protocol) ? 'https' : 'http'), u=p+'://fundin.douban.com/'; 1473 _paq.push(['setTrackerUrl', u+'piwik']); 1474 _paq.push(['setSiteId', '100001']); 1475 var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; 1476 g.type='text/javascript'; 1477 g.defer=true; 1478 g.async=true; 1479 g.src=p+'://img3.doubanio.com/dae/fundin/piwik.js'; 1480 s.parentNode.insertBefore(g,s); 1481 })(); 1482 </script> 1483 1484 <script type="text/javascript"> 1485 var setMethodWithNs = function(namespace) { 1486 var ns = namespace ? namespace + '.' : '' 1487 , fn = function(string) { 1488 if(!ns) {return string} 1489 return ns + string 1490 } 1491 return fn 1492 } 1493 1494 var gaWithNamespace = function(fn, namespace) { 1495 var method = setMethodWithNs(namespace) 1496 fn.call(this, method) 1497 } 1498 1499 var _gaq = _gaq || [] 1500 , accounts = [ 1501 { id: 'UA-7019765-1', namespace: 'douban' } 1502 , { id: 'UA-7019765-19', namespace: '' } 1503 ] 1504 , gaInit = function(account) { 1505 gaWithNamespace(function(method) { 1506 gaInitFn.call(this, method, account) 1507 }, account.namespace) 1508 } 1509 , gaInitFn = function(method, account) { 1510 _gaq.push([method('_setAccount'), account.id]); 1511 _gaq.push([method('_setSampleRate'), '5']); 1512 1513 1514 _gaq.push([method('_addOrganic'), 'google', 'q']) 1515 _gaq.push([method('_addOrganic'), 'baidu', 'wd']) 1516 _gaq.push([method('_addOrganic'), 'soso', 'w']) 1517 _gaq.push([method('_addOrganic'), 'youdao', 'q']) 1518 _gaq.push([method('_addOrganic'), 'so.360.cn', 'q']) 1519 _gaq.push([method('_addOrganic'), 'sogou', 'query']) 1520 if (account.namespace) { 1521 _gaq.push([method('_addIgnoredOrganic'), '豆瓣']) 1522 _gaq.push([method('_addIgnoredOrganic'), 'douban']) 1523 _gaq.push([method('_addIgnoredOrganic'), '豆瓣网']) 1524 _gaq.push([method('_addIgnoredOrganic'), 'www.douban.com']) 1525 } 1526 1527 if (account.namespace === 'douban') { 1528 _gaq.push([method('_setDomainName'), '.douban.com']) 1529 } 1530 1531 _gaq.push([method('_setCustomVar'), 1, 'responsive_view_mode', 'desktop', 3]) 1532 1533 _gaq.push([method('_setCustomVar'), 2, 'login_status', '0', 2]); 1534 1535 _gaq.push([method('_trackPageview')]) 1536 } 1537 1538 for(var i = 0, l = accounts.length; i < l; i++) { 1539 var account = accounts[i] 1540 gaInit(account) 1541 } 1542 1543 1544 ;(function() { 1545 var ga = document.createElement('script'); 1546 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 1547 ga.setAttribute('async', 'true'); 1548 document.documentElement.firstChild.appendChild(ga); 1549 })() 1550 </script> 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 <!-- anson24-docker--> 1563 1564 <script>_SPLITTEST=''</script> 1565 </body> 1566 1567 </html> 1568 '''
1 # 结构必须相似 2 from urllib.request import urlopen 3 import re 4 import json 5 6 def getPage(url): 7 response = urlopen(url) 8 content = response.read().decode('utf-8') 9 return content 10 11 def parsePage(s): 12 ret = com.finditer(s) 13 for i in ret: 14 yield { 15 'id': i.group('id'), 16 'title': i.group('title'), 17 'rating_num': i.group('rating_num'), 18 'comment_num': i.group('comment_num') 19 } 20 21 def main(num): 22 url = 'https://movie.douban.com/top250?start=%s&filter=' % num 23 response_html = getPage(url) 24 ret = parsePage(response_html) 25 print(ret) 26 f = open('move_info7', 'a', encoding='utf-8') 27 for obj in ret: 28 print(obj) 29 data = json.dumps(obj, ensure_ascii=False) 30 f.write(data + '\n') 31 f.close() 32 33 if __name__ == '__main__': 34 com = re.compile( 35 '<div class="item">.*?<div class="pic">.*?<em .*?>(?P<id>\d+).*?<span class="title">(?P<title>.*?)</span>' 36 '.*?<span class="rating_num" .*?>(?P<rating_num>.*?)</span>.*?<span>(?P<comment_num>.*?)评价</span>', re.S 37 ) 38 count = 0 39 for i in range(10): 40 main(count) 41 count += 25 42 ''' 43 <generator object parsePage at 0x01BEFF30> 44 {'id': '1', 'title': '肖申克的救赎', 'rating_num': '9.6', 'comment_num': '1136962人'} 45 {'id': '2', 'title': '霸王别姬', 'rating_num': '9.5', 'comment_num': '829150人'} 46 {'id': '3', 'title': '这个杀手不太冷', 'rating_num': '9.4', 'comment_num': '1051321人'} 47 {'id': '4', 'title': '阿甘正传', 'rating_num': '9.4', 'comment_num': '897476人'} 48 {'id': '5', 'title': '美丽人生', 'rating_num': '9.5', 'comment_num': '523574人'} 49 {'id': '6', 'title': '泰坦尼克号', 'rating_num': '9.3', 'comment_num': '834022人'} 50 {'id': '7', 'title': '千与千寻', 'rating_num': '9.3', 'comment_num': '833571人'} 51 {'id': '8', 'title': '辛德勒的名单', 'rating_num': '9.4', 'comment_num': '473283人'} 52 {'id': '9', 'title': '盗梦空间', 'rating_num': '9.3', 'comment_num': '921728人'} 53 {'id': '10', 'title': '机器人总动员', 'rating_num': '9.3', 'comment_num': '608268人'} 54 {'id': '11', 'title': '忠犬八公的故事', 'rating_num': '9.3', 'comment_num': '588076人'} 55 {'id': '12', 'title': '三傻大闹宝莱坞', 'rating_num': '9.2', 'comment_num': '827336人'} 56 {'id': '13', 'title': '海上钢琴师', 'rating_num': '9.2', 'comment_num': '696470人'} 57 {'id': '14', 'title': '放牛班的春天', 'rating_num': '9.2', 'comment_num': '563040人'} 58 {'id': '15', 'title': '大话西游之大圣娶亲', 'rating_num': '9.2', 'comment_num': '618510人'} 59 {'id': '16', 'title': '楚门的世界', 'rating_num': '9.1', 'comment_num': '594493人'} 60 {'id': '17', 'title': '教父', 'rating_num': '9.2', 'comment_num': '417774人'} 61 {'id': '18', 'title': '龙猫', 'rating_num': '9.1', 'comment_num': '513277人'} 62 {'id': '19', 'title': '星际穿越', 'rating_num': '9.2', 'comment_num': '616218人'} 63 {'id': '20', 'title': '熔炉', 'rating_num': '9.2', 'comment_num': '343601人'} 64 {'id': '21', 'title': '无间道', 'rating_num': '9.1', 'comment_num': '503485人'} 65 {'id': '22', 'title': '触不可及', 'rating_num': '9.2', 'comment_num': '446800人'} 66 {'id': '23', 'title': '乱世佳人', 'rating_num': '9.2', 'comment_num': '320494人'} 67 {'id': '24', 'title': '当幸福来敲门', 'rating_num': '9.0', 'comment_num': '662070人'} 68 {'id': '25', 'title': '怦然心动', 'rating_num': '9.0', 'comment_num': '707168人'} 69 <generator object parsePage at 0x01BEFF30> 70 {'id': '26', 'title': '疯狂动物城', 'rating_num': '9.1', 'comment_num': '664871人'} 71 {'id': '27', 'title': '天堂电影院', 'rating_num': '9.1', 'comment_num': '354924人'} 72 {'id': '28', 'title': '蝙蝠侠:黑暗骑士', 'rating_num': '9.1', 'comment_num': '407246人'} 73 {'id': '29', 'title': '十二怒汉', 'rating_num': '9.4', 'comment_num': '205261人'} 74 {'id': '30', 'title': '鬼子来了', 'rating_num': '9.2', 'comment_num': '284999人'} 75 {'id': '31', 'title': '活着', 'rating_num': '9.1', 'comment_num': '337078人'} 76 {'id': '32', 'title': '少年派的奇幻漂流', 'rating_num': '9.0', 'comment_num': '688467人'} 77 {'id': '33', 'title': '指环王3:王者无敌', 'rating_num': '9.1', 'comment_num': '339598人'} 78 {'id': '34', 'title': '搏击俱乐部', 'rating_num': '9.0', 'comment_num': '456266人'} 79 {'id': '35', 'title': '天空之城', 'rating_num': '9.0', 'comment_num': '396992人'} 80 {'id': '36', 'title': '控方证人', 'rating_num': '9.6', 'comment_num': '131614人'} 81 {'id': '37', 'title': '飞屋环游记', 'rating_num': '8.9', 'comment_num': '602132人'} 82 {'id': '38', 'title': '大话西游之月光宝盒', 'rating_num': '8.9', 'comment_num': '497513人'} 83 {'id': '39', 'title': '罗马假日', 'rating_num': '8.9', 'comment_num': '458021人'} 84 {'id': '40', 'title': '窃听风暴', 'rating_num': '9.1', 'comment_num': '269930人'} 85 {'id': '41', 'title': '两杆大烟枪', 'rating_num': '9.1', 'comment_num': '314374人'} 86 {'id': '42', 'title': '飞越疯人院', 'rating_num': '9.0', 'comment_num': '317552人'} 87 {'id': '43', 'title': '闻香识女人', 'rating_num': '8.9', 'comment_num': '387743人'} 88 {'id': '44', 'title': '哈尔的移动城堡', 'rating_num': '8.9', 'comment_num': '427326人'} 89 {'id': '45', 'title': '辩护人', 'rating_num': '9.2', 'comment_num': '265247人'} 90 {'id': '46', 'title': '摔跤吧!爸爸', 'rating_num': '9.1', 'comment_num': '592646人'} 91 {'id': '47', 'title': 'V字仇杀队', 'rating_num': '8.8', 'comment_num': '503120人'} 92 {'id': '48', 'title': '死亡诗社', 'rating_num': '9.0', 'comment_num': '333864人'} 93 {'id': '49', 'title': '海豚湾', 'rating_num': '9.3', 'comment_num': '208271人'} 94 {'id': '50', 'title': '教父2', 'rating_num': '9.1', 'comment_num': '225526人'} 95 <generator object parsePage at 0x01BEFF30> 96 {'id': '51', 'title': '指环王2:双塔奇兵', 'rating_num': '9.0', 'comment_num': '318720人'} 97 {'id': '52', 'title': '美丽心灵', 'rating_num': '8.9', 'comment_num': '356942人'} 98 {'id': '53', 'title': '指环王1:魔戒再现', 'rating_num': '8.9', 'comment_num': '356842人'} 99 {'id': '54', 'title': '饮食男女', 'rating_num': '9.1', 'comment_num': '243677人'} 100 {'id': '55', 'title': '情书', 'rating_num': '8.8', 'comment_num': '437267人'} 101 {'id': '56', 'title': '素媛', 'rating_num': '9.1', 'comment_num': '227577人'} 102 {'id': '57', 'title': '狮子王', 'rating_num': '8.9', 'comment_num': '334392人'} 103 {'id': '58', 'title': '美国往事', 'rating_num': '9.1', 'comment_num': '204073人'} 104 {'id': '59', 'title': '钢琴家', 'rating_num': '9.0', 'comment_num': '235336人'} 105 {'id': '60', 'title': '小鞋子', 'rating_num': '9.2', 'comment_num': '168125人'} 106 {'id': '61', 'title': '七宗罪', 'rating_num': '8.7', 'comment_num': '495474人'} 107 {'id': '62', 'title': '被嫌弃的松子的一生', 'rating_num': '8.9', 'comment_num': '350239人'} 108 {'id': '63', 'title': '天使爱美丽', 'rating_num': '8.7', 'comment_num': '551849人'} 109 {'id': '64', 'title': '致命魔术', 'rating_num': '8.8', 'comment_num': '402295人'} 110 {'id': '65', 'title': '本杰明·巴顿奇事', 'rating_num': '8.8', 'comment_num': '456274人'} 111 {'id': '66', 'title': '西西里的美丽传说', 'rating_num': '8.8', 'comment_num': '421224人'} 112 {'id': '67', 'title': '音乐之声', 'rating_num': '8.9', 'comment_num': '268975人'} 113 {'id': '68', 'title': '让子弹飞', 'rating_num': '8.7', 'comment_num': '741134人'} 114 {'id': '69', 'title': '黑客帝国', 'rating_num': '8.9', 'comment_num': '332788人'} 115 {'id': '70', 'title': '拯救大兵瑞恩', 'rating_num': '8.9', 'comment_num': '285251人'} 116 {'id': '71', 'title': '勇敢的心', 'rating_num': '8.8', 'comment_num': '331967人'} 117 {'id': '72', 'title': '看不见的客人', 'rating_num': '8.7', 'comment_num': '436278人'} 118 {'id': '73', 'title': '低俗小说', 'rating_num': '8.8', 'comment_num': '392959人'} 119 {'id': '74', 'title': '剪刀手爱德华', 'rating_num': '8.7', 'comment_num': '557365人'} 120 {'id': '75', 'title': '沉默的羔羊', 'rating_num': '8.8', 'comment_num': '405979人'} 121 <generator object parsePage at 0x01BEFF30> 122 {'id': '76', 'title': '大闹天宫', 'rating_num': '9.3', 'comment_num': '126269人'} 123 {'id': '77', 'title': '蝴蝶效应', 'rating_num': '8.7', 'comment_num': '442285人'} 124 {'id': '78', 'title': '末代皇帝', 'rating_num': '9.0', 'comment_num': '214162人'} 125 {'id': '79', 'title': '入殓师', 'rating_num': '8.8', 'comment_num': '352643人'} 126 {'id': '80', 'title': '春光乍泄', 'rating_num': '8.8', 'comment_num': '290099人'} 127 {'id': '81', 'title': '心灵捕手', 'rating_num': '8.8', 'comment_num': '319194人'} 128 {'id': '82', 'title': '玛丽和马克思', 'rating_num': '8.9', 'comment_num': '255687人'} 129 {'id': '83', 'title': '哈利·波特与魔法石', 'rating_num': '8.8', 'comment_num': '320109人'} 130 {'id': '84', 'title': '阳光灿烂的日子', 'rating_num': '8.8', 'comment_num': '316138人'} 131 {'id': '85', 'title': '布达佩斯大饭店', 'rating_num': '8.8', 'comment_num': '380840人'} 132 {'id': '86', 'title': '禁闭岛', 'rating_num': '8.7', 'comment_num': '420807人'} 133 {'id': '87', 'title': '幽灵公主', 'rating_num': '8.8', 'comment_num': '270444人'} 134 {'id': '88', 'title': '第六感', 'rating_num': '8.8', 'comment_num': '269686人'} 135 {'id': '89', 'title': '猫鼠游戏', 'rating_num': '8.8', 'comment_num': '280488人'} 136 {'id': '90', 'title': '重庆森林', 'rating_num': '8.7', 'comment_num': '384359人'} 137 {'id': '91', 'title': '狩猎', 'rating_num': '9.1', 'comment_num': '156862人'} 138 {'id': '92', 'title': '致命ID', 'rating_num': '8.7', 'comment_num': '369961人'} 139 {'id': '93', 'title': '断背山', 'rating_num': '8.7', 'comment_num': '368278人'} 140 {'id': '94', 'title': '大鱼', 'rating_num': '8.7', 'comment_num': '289042人'} 141 {'id': '95', 'title': '穿条纹睡衣的男孩', 'rating_num': '8.9', 'comment_num': '181575人'} 142 {'id': '96', 'title': '加勒比海盗', 'rating_num': '8.6', 'comment_num': '403853人'} 143 {'id': '97', 'title': '告白', 'rating_num': '8.7', 'comment_num': '391030人'} 144 {'id': '98', 'title': '甜蜜蜜', 'rating_num': '8.8', 'comment_num': '260975人'} 145 {'id': '99', 'title': '射雕英雄传之东成西就', 'rating_num': '8.7', 'comment_num': '314889人'} 146 {'id': '100', 'title': '一一', 'rating_num': '8.9', 'comment_num': '176905人'} 147 <generator object parsePage at 0x01BEFF30> 148 {'id': '101', 'title': '阿凡达', 'rating_num': '8.6', 'comment_num': '607396人'} 149 {'id': '102', 'title': '摩登时代', 'rating_num': '9.2', 'comment_num': '107574人'} 150 {'id': '103', 'title': '阳光姐妹淘', 'rating_num': '8.8', 'comment_num': '308629人'} 151 {'id': '104', 'title': '上帝之城', 'rating_num': '8.9', 'comment_num': '174373人'} 152 {'id': '105', 'title': '爱在黎明破晓前', 'rating_num': '8.7', 'comment_num': '256335人'} 153 {'id': '106', 'title': '消失的爱人', 'rating_num': '8.7', 'comment_num': '415421人'} 154 {'id': '107', 'title': '侧耳倾听', 'rating_num': '8.8', 'comment_num': '199098人'} 155 {'id': '108', 'title': '风之谷', 'rating_num': '8.8', 'comment_num': '200778人'} 156 {'id': '109', 'title': '爱在日落黄昏时', 'rating_num': '8.8', 'comment_num': '227021人'} 157 {'id': '110', 'title': '倩女幽魂', 'rating_num': '8.6', 'comment_num': '301352人'} 158 {'id': '111', 'title': '超脱', 'rating_num': '8.8', 'comment_num': '202665人'} 159 {'id': '112', 'title': '恐怖直播', 'rating_num': '8.7', 'comment_num': '265264人'} 160 {'id': '113', 'title': '红辣椒', 'rating_num': '8.9', 'comment_num': '159097人'} 161 {'id': '114', 'title': '小森林 夏秋篇', 'rating_num': '8.9', 'comment_num': '163081人'} 162 {'id': '115', 'title': '喜剧之王', 'rating_num': '8.6', 'comment_num': '373088人'} 163 {'id': '116', 'title': '菊次郎的夏天', 'rating_num': '8.7', 'comment_num': '216449人'} 164 {'id': '117', 'title': '驯龙高手', 'rating_num': '8.7', 'comment_num': '329730人'} 165 {'id': '118', 'title': '幸福终点站', 'rating_num': '8.7', 'comment_num': '254497人'} 166 {'id': '119', 'title': '借东西的小人阿莉埃蒂', 'rating_num': '8.7', 'comment_num': '247365人'} 167 {'id': '120', 'title': '神偷奶爸', 'rating_num': '8.5', 'comment_num': '441910人'} 168 {'id': '121', 'title': '萤火虫之墓', 'rating_num': '8.7', 'comment_num': '229344人'} 169 {'id': '122', 'title': '岁月神偷', 'rating_num': '8.6', 'comment_num': '338739人'} 170 {'id': '123', 'title': '七武士', 'rating_num': '9.2', 'comment_num': '88622人'} 171 {'id': '124', 'title': '杀人回忆', 'rating_num': '8.7', 'comment_num': '236531人'} 172 {'id': '125', 'title': '怪兽电力公司', 'rating_num': '8.6', 'comment_num': '280990人'} 173 <generator object parsePage at 0x01BEFF30> 174 {'id': '126', 'title': '谍影重重3', 'rating_num': '8.7', 'comment_num': '204388人'} 175 {'id': '127', 'title': '喜宴', 'rating_num': '8.8', 'comment_num': '159333人'} 176 {'id': '128', 'title': '贫民窟的百万富翁', 'rating_num': '8.5', 'comment_num': '433139人'} 177 {'id': '129', 'title': '电锯惊魂', 'rating_num': '8.7', 'comment_num': '223295人'} 178 {'id': '130', 'title': '真爱至上', 'rating_num': '8.5', 'comment_num': '349284人'} 179 {'id': '131', 'title': '东邪西毒', 'rating_num': '8.6', 'comment_num': '287068人'} 180 {'id': '132', 'title': '记忆碎片', 'rating_num': '8.6', 'comment_num': '313381人'} 181 {'id': '133', 'title': '黑天鹅', 'rating_num': '8.5', 'comment_num': '465339人'} 182 {'id': '134', 'title': '疯狂原始人', 'rating_num': '8.7', 'comment_num': '417114人'} 183 {'id': '135', 'title': '雨人', 'rating_num': '8.6', 'comment_num': '229786人'} 184 {'id': '136', 'title': '海洋', 'rating_num': '9.0', 'comment_num': '105731人'} 185 {'id': '137', 'title': '小森林 冬春篇', 'rating_num': '8.9', 'comment_num': '141001人'} 186 {'id': '138', 'title': '哈利·波特与死亡圣器(下)', 'rating_num': '8.7', 'comment_num': '313421人'} 187 {'id': '139', 'title': '卢旺达饭店', 'rating_num': '8.9', 'comment_num': '136575人'} 188 {'id': '140', 'title': '请以你的名字呼唤我', 'rating_num': '8.8', 'comment_num': '215180人'} 189 {'id': '141', 'title': '萤火之森', 'rating_num': '8.8', 'comment_num': '188466人'} 190 {'id': '142', 'title': '英雄本色', 'rating_num': '8.6', 'comment_num': '198786人'} 191 {'id': '143', 'title': '7号房的礼物', 'rating_num': '8.7', 'comment_num': '205810人'} 192 {'id': '144', 'title': '心迷宫', 'rating_num': '8.6', 'comment_num': '210739人'} 193 {'id': '145', 'title': '虎口脱险', 'rating_num': '8.9', 'comment_num': '118205人'} 194 {'id': '146', 'title': '燃情岁月', 'rating_num': '8.7', 'comment_num': '161251人'} 195 {'id': '147', 'title': '荒蛮故事', 'rating_num': '8.8', 'comment_num': '168403人'} 196 {'id': '148', 'title': '傲慢与偏见', 'rating_num': '8.5', 'comment_num': '344035人'} 197 {'id': '149', 'title': '超能陆战队', 'rating_num': '8.6', 'comment_num': '428756人'} 198 {'id': '150', 'title': '海边的曼彻斯特', 'rating_num': '8.6', 'comment_num': '231798人'} 199 <generator object parsePage at 0x01BEFF30> 200 {'id': '151', 'title': '蝙蝠侠:黑暗骑士崛起', 'rating_num': '8.6', 'comment_num': '332241人'} 201 {'id': '152', 'title': '唐伯虎点秋香', 'rating_num': '8.4', 'comment_num': '391028人'} 202 {'id': '153', 'title': '教父3', 'rating_num': '8.8', 'comment_num': '150140人'} 203 {'id': '154', 'title': '纵横四海', 'rating_num': '8.7', 'comment_num': '170601人'} 204 {'id': '155', 'title': '恋恋笔记本', 'rating_num': '8.5', 'comment_num': '320328人'} 205 {'id': '156', 'title': '玩具总动员3', 'rating_num': '8.8', 'comment_num': '215398人'} 206 {'id': '157', 'title': '完美的世界', 'rating_num': '9.0', 'comment_num': '93344人'} 207 {'id': '158', 'title': '时空恋旅人', 'rating_num': '8.6', 'comment_num': '234868人'} 208 {'id': '159', 'title': '花样年华', 'rating_num': '8.5', 'comment_num': '277064人'} 209 {'id': '160', 'title': '达拉斯买家俱乐部', 'rating_num': '8.7', 'comment_num': '210179人'} 210 {'id': '161', 'title': '猜火车', 'rating_num': '8.5', 'comment_num': '270902人'} 211 {'id': '162', 'title': '魂断蓝桥', 'rating_num': '8.8', 'comment_num': '142255人'} 212 {'id': '163', 'title': '雨中曲', 'rating_num': '9.0', 'comment_num': '102866人'} 213 {'id': '164', 'title': '穿越时空的少女', 'rating_num': '8.6', 'comment_num': '205342人'} 214 {'id': '165', 'title': '二十二', 'rating_num': '8.7', 'comment_num': '122817人'} 215 {'id': '166', 'title': '无人知晓', 'rating_num': '9.1', 'comment_num': '83749人'} 216 {'id': '167', 'title': '我是山姆', 'rating_num': '8.8', 'comment_num': '118954人'} 217 {'id': '168', 'title': '冰川时代', 'rating_num': '8.5', 'comment_num': '306556人'} 218 {'id': '169', 'title': '人工智能', 'rating_num': '8.6', 'comment_num': '212679人'} 219 {'id': '170', 'title': '血战钢锯岭', 'rating_num': '8.7', 'comment_num': '367970人'} 220 {'id': '171', 'title': '浪潮', 'rating_num': '8.7', 'comment_num': '147530人'} 221 {'id': '172', 'title': '爆裂鼓手', 'rating_num': '8.6', 'comment_num': '267524人'} 222 {'id': '173', 'title': '朗读者', 'rating_num': '8.5', 'comment_num': '299592人'} 223 {'id': '174', 'title': '香水', 'rating_num': '8.4', 'comment_num': '306173人'} 224 {'id': '175', 'title': '罗生门', 'rating_num': '8.7', 'comment_num': '142114人'} 225 <generator object parsePage at 0x01BEFF30> 226 {'id': '176', 'title': '未麻的部屋', 'rating_num': '8.8', 'comment_num': '113769人'} 227 {'id': '177', 'title': '被解救的姜戈', 'rating_num': '8.6', 'comment_num': '288746人'} 228 {'id': '178', 'title': '阿飞正传', 'rating_num': '8.5', 'comment_num': '234013人'} 229 {'id': '179', 'title': '头脑特工队', 'rating_num': '8.7', 'comment_num': '263741人'} 230 {'id': '180', 'title': '可可西里', 'rating_num': '8.7', 'comment_num': '143587人'} 231 {'id': '181', 'title': '恐怖游轮', 'rating_num': '8.4', 'comment_num': '368793人'} 232 {'id': '182', 'title': '一次别离', 'rating_num': '8.7', 'comment_num': '145765人'} 233 {'id': '183', 'title': '追随', 'rating_num': '8.9', 'comment_num': '90823人'} 234 {'id': '184', 'title': '房间', 'rating_num': '8.8', 'comment_num': '180160人'} 235 {'id': '185', 'title': '撞车', 'rating_num': '8.6', 'comment_num': '189974人'} 236 {'id': '186', 'title': '战争之王', 'rating_num': '8.6', 'comment_num': '190742人'} 237 {'id': '187', 'title': '你的名字。', 'rating_num': '8.4', 'comment_num': '556781人'} 238 {'id': '188', 'title': '地球上的星星', 'rating_num': '8.8', 'comment_num': '96033人'} 239 {'id': '189', 'title': '魔女宅急便', 'rating_num': '8.5', 'comment_num': '219378人'} 240 {'id': '190', 'title': '模仿游戏', 'rating_num': '8.6', 'comment_num': '287770人'} 241 {'id': '191', 'title': '牯岭街少年杀人事件', 'rating_num': '8.8', 'comment_num': '120103人'} 242 {'id': '192', 'title': '谍影重重', 'rating_num': '8.5', 'comment_num': '214008人'} 243 {'id': '193', 'title': '梦之安魂曲', 'rating_num': '8.7', 'comment_num': '123207人'} 244 {'id': '194', 'title': '忠犬八公物语', 'rating_num': '9.0', 'comment_num': '70288人'} 245 {'id': '195', 'title': '一个叫欧维的男人决定去死', 'rating_num': '8.7', 'comment_num': '143164人'} 246 {'id': '196', 'title': '谍影重重2', 'rating_num': '8.6', 'comment_num': '177752人'} 247 {'id': '197', 'title': '完美陌生人', 'rating_num': '8.6', 'comment_num': '235389人'} 248 {'id': '198', 'title': '惊魂记', 'rating_num': '8.9', 'comment_num': '94874人'} 249 {'id': '199', 'title': '青蛇', 'rating_num': '8.5', 'comment_num': '249062人'} 250 {'id': '200', 'title': '哪吒闹海', 'rating_num': '8.9', 'comment_num': '92535人'} 251 <generator object parsePage at 0x01BEFF30> 252 {'id': '201', 'title': '再次出发之纽约遇见你', 'rating_num': '8.5', 'comment_num': '194801人'} 253 {'id': '202', 'title': '小萝莉的猴神大叔', 'rating_num': '8.5', 'comment_num': '190138人'} 254 {'id': '203', 'title': '黑客帝国3:矩阵革命', 'rating_num': '8.6', 'comment_num': '175795人'} 255 {'id': '204', 'title': '东京物语', 'rating_num': '9.2', 'comment_num': '58021人'} 256 {'id': '205', 'title': '新龙门客栈', 'rating_num': '8.5', 'comment_num': '207001人'} 257 {'id': '206', 'title': '源代码', 'rating_num': '8.4', 'comment_num': '445325人'} 258 {'id': '207', 'title': '终结者2:审判日', 'rating_num': '8.6', 'comment_num': '156077人'} 259 {'id': '208', 'title': '末路狂花', 'rating_num': '8.7', 'comment_num': '116215人'} 260 {'id': '209', 'title': '绿里奇迹', 'rating_num': '8.7', 'comment_num': '118647人'} 261 {'id': '210', 'title': '步履不停', 'rating_num': '8.8', 'comment_num': '97773人'} 262 {'id': '211', 'title': '秒速5厘米', 'rating_num': '8.3', 'comment_num': '336378人'} 263 {'id': '212', 'title': '碧海蓝天', 'rating_num': '8.7', 'comment_num': '113548人'} 264 {'id': '213', 'title': '海街日记', 'rating_num': '8.7', 'comment_num': '155736人'} 265 {'id': '214', 'title': '初恋这件小事', 'rating_num': '8.3', 'comment_num': '511023人'} 266 {'id': '215', 'title': '城市之光', 'rating_num': '9.2', 'comment_num': '50588人'} 267 {'id': '216', 'title': '这个男人来自地球', 'rating_num': '8.5', 'comment_num': '201836人'} 268 {'id': '217', 'title': '勇闯夺命岛', 'rating_num': '8.6', 'comment_num': '154771人'} 269 {'id': '218', 'title': '无敌破坏王', 'rating_num': '8.7', 'comment_num': '207232人'} 270 {'id': '219', 'title': '无耻混蛋', 'rating_num': '8.5', 'comment_num': '244884人'} 271 {'id': '220', 'title': '爱在午夜降临前', 'rating_num': '8.8', 'comment_num': '131277人'} 272 {'id': '221', 'title': '海盗电台', 'rating_num': '8.6', 'comment_num': '176536人'} 273 {'id': '222', 'title': '卡萨布兰卡', 'rating_num': '8.6', 'comment_num': '136479人'} 274 {'id': '223', 'title': '疯狂的石头', 'rating_num': '8.3', 'comment_num': '354627人'} 275 {'id': '224', 'title': '变脸', 'rating_num': '8.4', 'comment_num': '233253人'} 276 {'id': '225', 'title': 'E.T. 外星人', 'rating_num': '8.5', 'comment_num': '170281人'} 277 <generator object parsePage at 0x01BEFF30> 278 {'id': '226', 'title': '发条橙', 'rating_num': '8.5', 'comment_num': '202041人'} 279 {'id': '227', 'title': '黄金三镖客', 'rating_num': '9.1', 'comment_num': '57570人'} 280 {'id': '228', 'title': '美国丽人', 'rating_num': '8.5', 'comment_num': '202029人'} 281 {'id': '229', 'title': '彗星来的那一夜', 'rating_num': '8.4', 'comment_num': '207481人'} 282 {'id': '230', 'title': '荒野生存', 'rating_num': '8.6', 'comment_num': '138526人'} 283 {'id': '231', 'title': '英国病人', 'rating_num': '8.5', 'comment_num': '186720人'} 284 {'id': '232', 'title': '迁徙的鸟', 'rating_num': '9.1', 'comment_num': '55075人'} 285 {'id': '233', 'title': '血钻', 'rating_num': '8.5', 'comment_num': '149126人'} 286 {'id': '234', 'title': '聚焦', 'rating_num': '8.8', 'comment_num': '142728人'} 287 {'id': '235', 'title': '国王的演讲', 'rating_num': '8.3', 'comment_num': '371667人'} 288 {'id': '236', 'title': '非常嫌疑犯', 'rating_num': '8.6', 'comment_num': '128198人'} 289 {'id': '237', 'title': '燕尾蝶', 'rating_num': '8.6', 'comment_num': '113716人'} 290 {'id': '238', 'title': '勇士', 'rating_num': '8.9', 'comment_num': '94355人'} 291 {'id': '239', 'title': '黑鹰坠落', 'rating_num': '8.6', 'comment_num': '130601人'} 292 {'id': '240', 'title': '穆赫兰道', 'rating_num': '8.3', 'comment_num': '254945人'} 293 {'id': '241', 'title': '遗愿清单', 'rating_num': '8.5', 'comment_num': '145700人'} 294 {'id': '242', 'title': '叫我第一名', 'rating_num': '8.6', 'comment_num': '117631人'} 295 {'id': '243', 'title': '我爱你', 'rating_num': '9.0', 'comment_num': '65021人'} 296 {'id': '244', 'title': '枪火', 'rating_num': '8.6', 'comment_num': '109640人'} 297 {'id': '245', 'title': '荒岛余生', 'rating_num': '8.5', 'comment_num': '149701人'} 298 {'id': '246', 'title': '2001太空漫游', 'rating_num': '8.7', 'comment_num': '105862人'} 299 {'id': '247', 'title': '上帝也疯狂', 'rating_num': '8.6', 'comment_num': '103665人'} 300 {'id': '248', 'title': '千钧一发', 'rating_num': '8.7', 'comment_num': '96480人'} 301 {'id': '249', 'title': '大卫·戈尔的一生', 'rating_num': '8.6', 'comment_num': '105386人'} 302 {'id': '250', 'title': '蓝色大门', 'rating_num': '8.3', 'comment_num': '289390人'} 303 '''
二、异常处理
语法错误:在程序之前就规避掉,不应该留到程序中来进行异常处理
在编译的过程中报错
异常:
在编译阶段没问题,在执行阶段才报错
异常出现之后的现象:程序就不继续执行了
Python的异常种类:
# 常见异常 AttributeError # 试图访问一个对象没有的树形,比如foo.x,但是foo没有属性x IOError # 输入/输出异常;基本上是无法打开文件 ImportError # 无法引入模块或包;基本上是路径问题或名称错误 IndentationError # 语法错误(的子类) ;代码没有正确对齐 IndexError # 下标索引超出序列边界,比如当x只有三个元素,却试图访问x[5] KeyError # 试图访问字典里不存在的键 KeyboardInterrupt # Ctrl+C被按下 NameError # 使用一个还未被赋予对象的变量 SyntaxError # Python代码非法,代码不能编译(个人认为这是语法错误,写错了) TypeError # 传入对象类型与要求的不符合 UnboundLocalError # 试图访问一个还未被设置的局部变量,基本上是由于另有一个同名的全局变量,导致你以为正在访问它 ValueError # 传入一个调用者不期望的值,即使值的类型是正确的
ArithmeticError
AssertionError
AttributeError
BaseException
BufferError
BytesWarning
DeprecationWarning
EnvironmentError
EOFError
Exception
FloatingPointError
FutureWarning
GeneratorExit
ImportError
ImportWarning
IndentationError
IndexError
IOError
KeyboardInterrupt
KeyError
LookupError
MemoryError
NameError
NotImplementedError
OSError
OverflowError
PendingDeprecationWarning
ReferenceError
RuntimeError
RuntimeWarning
StandardError
StopIteration
SyntaxError
SyntaxWarning
SystemError
SystemExit
TabError
TypeError
UnboundLocalError
UnicodeDecodeError
UnicodeEncodeError
UnicodeError
UnicodeTranslateError
UnicodeWarning
UserWarning
ValueError
Warning
ZeroDivisionError
异常处理:
1、基本语法:
# try: # 被检测的代码块 # except 异常类型: # try中一旦检测到异常,就执行这个位置的逻辑 l = ['登录', '注册'] try: num = int(input('num:')) print(l[num - 1]) except ValueError: # 输入的不是数字走这里 print('输入的不是数字') except IndexError: # 输入的数字超出范围走这里 print('输入的超出范围') try: num = int(input('num:')) print(l[num - 1]) except (ValueError,IndexError): # 把不同的报错类型写在一起 print('输入了错误的内容')
2、万能异常 Exception
# 万能异常Exception
try: l = [] l[3] # IndexError import Index # ModuleNotFoundError open('aaaaaa') # FileNotFoundError 1/0 # ZeroDivisionError dic = {} dic['k'] # KeyError except Exception: print('异常了') # as 语法 try: l = [] l[3] # IndexError import Index # ModuleNotFoundError open('aaaaaa') # FileNotFoundError 1/0 # ZeroDivisionError dic = {} dic['k'] # KeyError except Exception as e: print(e) # list index out of range # 多分支 + 万能异常 l = ['登陆','注册'] try: num = int(input('num : ')) print(l[num - 1]) except (ValueError,IndexError): # 异常是这两种错误则走这里 print('输入了错误的内容') except Exception as e: # 如果不是上面两种错误则走这里 print(e)
3、异常处理中的其他机制
s1 = 'hello' try: int(s1) except IndexError as e: print(e) except KeyError as e: print(e) except ValueError as e: print(e) #except Exception as e: # print(e) else: print('try内代码块没有异常则执行我') # 汇报这段代码顺利的执行了:发短信通知,记录到文件中 finally: print('无论异常与否,都会执行该模块,通常是进行清理工作') # 无论如何都要执行 # 收尾工作,打开了一个文件,占用了一个网络资源,打开了一个和数据库的链接 # 可以在这里关闭文件等
4、主动触发异常
try: raise TypeError('类型错误') except Exception as e: print(e) # 类型错误
5、自定义异常
class EvaException(BaseException): def __init__(self,msg): self.msg=msg def __str__(self): return self.msg try: raise EvaException('类型错误') except EvaException as e: print(e) # 类型错误
6、断言
assert 1 == 1 print('*' * 10) # ********** assert 1 == 2 print('*' * 10) # AssertionError