网络爬虫学习(十二)
之前(https://blog.csdn.net/weixin_44526949/article/details/86738980)學習了Selenium模塊的使用,這個模塊,我們知道是用來驅動瀏覽器來完成一些操作,比如元素的交互,頁面的跳轉等等。那么從這篇之后,會進行一些實際的爬蟲項目。首先,我們來完成一個電影網站的爬蟲項目。這個電影網站是一個貓眼電影網站(https://maoyan.com)。我們所要做的就是爬取這個網站的榜單內容的TOP100(https://maoyan.com/board/4)。
首先,我們來進行下網頁的代碼分析:
我們可以通過"檢查"來查看不同的網頁內容所對應的代碼,然后通過對代碼的分析,來進行對應內容的爬取。
整個流程框架如下:
1、抓取單頁內容:利用requests請求目標站點,得到單個網頁的HTML代碼,返回結果。
2、正則表達式分析:根據HTML代碼分析得到電影的名稱、主演、上映時間、評分、圖片鏈接等信息。
3、保存至文件:通過文件的形式將結果保存,每一部電影一個結果一行Json字符串。
4、開啟循環及多線程:對多頁內容遍歷,開啟多線程提高抓取速度。
在開始爬取時,由于我們要爬取top100,這顯然需要跨頁獲取,因此,首先,先完成一個頁面的爬取,成功爬取之后,我們可以通過觀察網頁的url規律,來掌握從一個頁面跳轉到同類型的另一個頁面,它的url如何變化,一般都是在當前頁的url后面稍微做了點改變,很容易捕捉到規律,進而使用循環來遍歷所有的指定內容的頁面即可,最后將我們爬取到的結果保存起來,可以保存到本地文件,也可以保存到數據庫,供我們以后使用。
了解了整個環節后,開始完成這個項目。
首先建議一個項目文件夾,取名為Maoyantop100,然后在該文件夾下,編寫我們的一個模塊spider.py。內容如下:
import requests from requests.exceptions import RequestException import re import json # 獲取目標url的單個的頁面 def get_one_page(url):try:response = requests.get(url)if response.status_code == 200:return response.textreturn Noneexcept RequestException:return None # 對網頁內容進行解析 def parse_one_page(html):pattern = re.compile('<dd>.*?board-index.*?>(\d+)</i>.*?data-src="(.*?)".*?name"><a'+'.*?>(.*?)</a>.*?star">(.*?)</p>.*?releasetime">(.*?)</p>'+'.*?integer">(.*?)</i>.*?fraction">(.*?)</i>.*?</dd>', re.S)items = re.findall(pattern, html)#print(items)for item in items:yield {'index': item[0],'image': item[1],'title': item[2],'actor': item[3].strip()[3:],'time': item[4].strip()[5:],'score': item[5] + item[6]}def write_to_file(content):with open("result.txt", 'a', encoding='utf-8') as f:f.write(json.dumps(content, ensure_ascii=False) + "\n")f.close()def main(offset):url = 'https://maoyan.com/board/4?offset=' + str(offset)html = get_one_page(url)#print(html)#parse_one_page(html)"""for item in parse_one_page(html):print(item)"""for item in parse_one_page(html):write_to_file(item)if __name__ == "__main__":for i in range(10):main(i*10)運行程序后,在我們的保存模塊中,將結果寫入到了一個文件中,文件內容如下所示:
{"index": "1", "image": "https://p1.meituan.net/movie/20803f59291c47e1e116c11963ce019e68711.jpg@160w_220h_1e_1c", "title": "霸王別姬", "actor": "張國榮,張豐毅,鞏俐", "time": "1993-01-01", "score": "9.6"} {"index": "2", "image": "https://p0.meituan.net/movie/283292171619cdfd5b240c8fd093f1eb255670.jpg@160w_220h_1e_1c", "title": "肖申克的救贖", "actor": "蒂姆·羅賓斯,摩根·弗里曼,鮑勃·岡頓", "time": "1994-10-14(美國)", "score": "9.5"} {"index": "3", "image": "https://p0.meituan.net/movie/54617769d96807e4d81804284ffe2a27239007.jpg@160w_220h_1e_1c", "title": "羅馬假日", "actor": "格利高里·派克,奧黛麗·赫本,埃迪·艾伯特", "time": "1953-09-02(美國)", "score": "9.1"} {"index": "4", "image": "https://p0.meituan.net/movie/e55ec5d18ccc83ba7db68caae54f165f95924.jpg@160w_220h_1e_1c", "title": "這個殺手不太冷", "actor": "讓·雷諾,加里·奧德曼,娜塔莉·波特曼", "time": "1994-09-14(法國)", "score": "9.5"} {"index": "5", "image": "https://p1.meituan.net/movie/0699ac97c82cf01638aa5023562d6134351277.jpg@160w_220h_1e_1c", "title": "泰坦尼克號", "actor": "萊昂納多·迪卡普里奧,凱特·溫絲萊特,比利·贊恩", "time": "1998-04-03", "score": "9.6"} {"index": "6", "image": "https://p1.meituan.net/movie/f5a924f362f050881f2b8f82e852747c118515.jpg@160w_220h_1e_1c", "title": "教父", "actor": "馬龍·白蘭度,阿爾·帕西諾,詹姆斯·肯恩", "time": "1972-03-24(美國)", "score": "9.3"} {"index": "7", "image": "https://p0.meituan.net/movie/da64660f82b98cdc1b8a3804e69609e041108.jpg@160w_220h_1e_1c", "title": "唐伯虎點秋香", "actor": "周星馳,鞏俐,鄭佩佩", "time": "1993-07-01(中國香港)", "score": "9.2"} {"index": "8", "image": "https://p0.meituan.net/movie/b076ce63e9860ecf1ee9839badee5228329384.jpg@160w_220h_1e_1c", "title": "千與千尋", "actor": "柊瑠美,入野自由,夏木真理", "time": "2001-07-20(日本)", "score": "9.3"} {"index": "9", "image": "https://p0.meituan.net/movie/46c29a8b8d8424bdda7715e6fd779c66235684.jpg@160w_220h_1e_1c", "title": "魂斷藍橋", "actor": "費雯·麗,羅伯特·泰勒,露塞爾·沃特森", "time": "1940-05-17(美國)", "score": "9.2"} {"index": "10", "image": "https://p0.meituan.net/movie/230e71d398e0c54730d58dc4bb6e4cca51662.jpg@160w_220h_1e_1c", "title": "亂世佳人", "actor": "費雯·麗,克拉克·蓋博,奧利維婭·德哈維蘭", "time": "1939-12-15(美國)", "score": "9.1"} {"index": "11", "image": "https://p1.meituan.net/movie/ba1ed511668402605ed369350ab779d6319397.jpg@160w_220h_1e_1c", "title": "天空之城", "actor": "寺田農,鷲尾真知子,龜山助清", "time": "1992", "score": "9.1"} {"index": "12", "image": "https://p1.meituan.net/movie/18e3191039d5e71562477659301f04aa61905.jpg@160w_220h_1e_1c", "title": "喜劇之王", "actor": "周星馳,莫文蔚,張柏芝", "time": "1999-02-13(中國香港)", "score": "9.2"} {"index": "13", "image": "https://p1.meituan.net/movie/39ed7a0941a3604bba78d299b11a18ce119679.jpg@160w_220h_1e_1c", "title": "辛德勒的名單", "actor": "連姆·尼森,拉爾夫·費因斯,本·金斯利", "time": "1993-12-15(美國)", "score": "9.2"} {"index": "14", "image": "https://p1.meituan.net/movie/14a7b337e8063e3ce05a5993ed80176b74208.jpg@160w_220h_1e_1c", "title": "大鬧天宮", "actor": "邱岳峰,畢克,富潤生", "time": "1965-12-31", "score": "9.0"} {"index": "15", "image": "https://p1.meituan.net/movie/6bc004d57358ee6875faa5e9a1239140128550.jpg@160w_220h_1e_1c", "title": "音樂之聲", "actor": "朱莉·安德魯斯,克里斯托弗·普盧默,埃琳諾·帕克", "time": "1965-03-02(美國)", "score": "9.0"} {"index": "16", "image": "https://p1.meituan.net/movie/0e91ffcfa7e53449216cc29ee8af513a75791.jpg@160w_220h_1e_1c", "title": "剪刀手愛德華", "actor": "約翰尼·德普,薇諾娜·瑞德,黛安·韋斯特", "time": "1990-12-06(美國)", "score": "8.8"} {"index": "17", "image": "https://p0.meituan.net/movie/ae7245920d95c03765fe1615f3a1fe3865785.jpg@160w_220h_1e_1c", "title": "春光乍泄", "actor": "張國榮,梁朝偉,張震", "time": "1997-05-30(中國香港)", "score": "9.2"} {"index": "18", "image": "https://p0.meituan.net/movie/43d259ecbcd53e8bbe902632772281d6327525.jpg@160w_220h_1e_1c", "title": "美麗人生", "actor": "羅伯托·貝尼尼,尼可萊塔·布拉斯基,喬治·坎塔里尼", "time": "1997-12-20(意大利)", "score": "9.3"} {"index": "19", "image": "https://p1.meituan.net/movie/c15b7623cce2f51c75562a3baefe507b68290.jpg@160w_220h_1e_1c", "title": "海上鋼琴師", "actor": "蒂姆·羅斯,普路特·泰勒·文斯,比爾·努恩", "time": "1998-10-28(意大利)", "score": "9.2"} {"index": "20", "image": "https://p1.meituan.net/movie/d981a12f59d3cc92ff666094404ad8f0211220.jpg@160w_220h_1e_1c", "title": "黑客帝國", "actor": "基努·里維斯,凱瑞-安·莫斯,勞倫斯·菲什伯恩", "time": "2000-01-14", "score": "9.0"} {"index": "21", "image": "https://p1.meituan.net/movie/aacb9ed2a6601bfe515ef0970add1715623792.jpg@160w_220h_1e_1c", "title": "哈利·波特與魔法石", "actor": "丹尼爾·雷德克里夫,魯伯特·格林特,艾瑪·沃特森", "time": "2002-01-26", "score": "9.1"} {"index": "22", "image": "https://p1.meituan.net/movie/b449893ebc63d5c54eb4a5b60341f334383831.jpg@160w_220h_1e_1c", "title": "加勒比海盜", "actor": "約翰尼·德普,凱拉·奈特莉,奧蘭多·布魯姆", "time": "2003-11-21", "score": "8.9"} {"index": "23", "image": "https://p0.meituan.net/movie/932bdfbef5be3543e6b136246aeb99b8123736.jpg@160w_220h_1e_1c", "title": "指環王3:王者無敵", "actor": "伊萊賈·伍德,伊恩·麥克萊恩,麗芙·泰勒", "time": "2004-03-15", "score": "9.2"} {"index": "24", "image": "https://p1.meituan.net/movie/53b6f0b66882a53b08896c92076515a8236400.jpg@160w_220h_1e_1c", "title": "射雕英雄傳之東成西就", "actor": "張國榮,梁朝偉,張學友", "time": "1993-02-05(中國香港)", "score": "8.9"} {"index": "25", "image": "https://p1.meituan.net/movie/0d93b5b585ce29c6688e43f3989fb41f86421.jpg@160w_220h_1e_1c", "title": "無間道", "actor": "劉德華,梁朝偉,黃秋生", "time": "2003-09-05", "score": "9.1"} {"index": "26", "image": "https://p0.meituan.net/movie/8959888ee0c399b0fe53a714bc8a5a17460048.jpg@160w_220h_1e_1c", "title": "楚門的世界", "actor": "金·凱瑞,勞拉·琳妮,諾亞·艾默里奇", "time": "1998-06-01(美國)", "score": "8.9"} {"index": "27", "image": "https://p0.meituan.net/movie/d12a1c198ad9ffac72b5db57feacb449294699.jpg@160w_220h_1e_1c", "title": "蝙蝠俠:黑暗騎士", "actor": "克里斯蒂安·貝爾,希斯·萊杰,阿倫·伊克哈特", "time": "2008-07-18(美國)", "score": "9.3"} {"index": "28", "image": "https://p1.meituan.net/movie/7bac8bfa6739c18620065132ce9c64fa85110.jpg@160w_220h_1e_1c", "title": "教父2", "actor": "阿爾·帕西諾,羅伯特·德尼羅,黛安·基頓", "time": "1974-12-12(美國)", "score": "9.0"} {"index": "29", "image": "https://p0.meituan.net/movie/5cfa597a98b35ee4ee598695942641ba287922.jpg@160w_220h_1e_1c", "title": "指環王2:雙塔奇兵", "actor": "伊萊賈·伍德,伊恩·麥克萊恩,麗芙·泰勒", "time": "2003-04-25", "score": "9.1"} {"index": "30", "image": "https://p1.meituan.net/movie/4592eef6b6dffcd1d950f55f41ab098f239816.jpg@160w_220h_1e_1c", "title": "機器人總動員", "actor": "本·貝爾特,艾麗莎·奈特,杰夫·格爾林", "time": "2008-06-27(美國)", "score": "9.3"} {"index": "31", "image": "https://p1.meituan.net/movie/618e57ddb3173de6bbf2e278946b11f279679.jpg@160w_220h_1e_1c", "title": "天堂電影院", "actor": "菲利浦·諾瓦雷,賽爾喬·卡斯特利托,蒂茲亞娜·羅達托", "time": "1988-11-17(意大利)", "score": "9.2"} {"index": "32", "image": "https://p0.meituan.net/movie/4c41068ef7608c1d4fbfbe6016e589f7204391.jpg@160w_220h_1e_1c", "title": "活著", "actor": "葛優,鞏俐,牛犇", "time": "1994-05-18(法國)", "score": "9.0"} {"index": "33", "image": "https://p1.meituan.net/movie/779bcc212a50a2526343362778f6b63c334618.jpg@160w_220h_1e_1c", "title": "拯救大兵瑞恩", "actor": "湯姆·漢克斯,馬特·達蒙,湯姆·塞茲摩爾", "time": "1998-07-24(美國)", "score": "8.9"} {"index": "34", "image": "https://p0.meituan.net/movie/0127b451d5b8f0679c6f81c8ed414bb2432442.jpg@160w_220h_1e_1c", "title": "哈爾的移動城堡", "actor": "倍賞千惠子,木村拓哉,美輪明宏", "time": "2004-11-20(日本)", "score": "9.0"} {"index": "35", "image": "https://p1.meituan.net/movie/91f575ec93f019f428d1f33e3ceca7c5115495.jpg@160w_220h_1e_1c", "title": "阿凡達", "actor": "薩姆·沃辛頓,佐伊·索爾達娜,米歇爾·羅德里格茲", "time": "2010-01-04", "score": "9.1"} {"index": "36", "image": "https://p1.meituan.net/movie/2f344a9f9575edbcae9f0abe0578bc90339773.jpg@160w_220h_1e_1c", "title": "盜夢空間", "actor": "萊昂納多·迪卡普里奧,渡邊謙,約瑟夫·高登-萊維特", "time": "2010-09-01", "score": "9.2"} {"index": "37", "image": "https://p0.meituan.net/movie/7787c10ad5e95b03cf83ef9473500d8e282796.jpg@160w_220h_1e_1c", "title": "忠犬八公的故事", "actor": "Forest,理查·基爾,瓊·艾倫", "time": "2010-03-12(英國)", "score": "9.3"} {"index": "38", "image": "https://p0.meituan.net/movie/6ab1882a217e848acceb240365043d53329196.jpg@160w_220h_1e_1c", "title": "幽靈公主", "actor": "松田洋治,石田百合子,田中裕子", "time": "1997-07-12(日本)", "score": "8.9"} {"index": "39", "image": "https://p1.meituan.net/movie/c5e76795bf7a78b12a2ffabb4a0c5c11112921.jpg@160w_220h_1e_1c", "title": "搏擊俱樂部", "actor": "愛德華·哈里森·諾頓,布拉德·皮特,海倫娜·伯翰·卡特", "time": "1999-10-15(美國)", "score": "8.8"} {"index": "40", "image": "https://p1.meituan.net/movie/7e471a9171a410ebc9413b2f1de67afc130067.jpg@160w_220h_1e_1c", "title": "東邪西毒", "actor": "張國榮,梁朝偉,劉嘉玲", "time": "1994-09-17", "score": "8.8"} {"index": "41", "image": "https://p0.meituan.net/movie/4f9638ba234c3fb673f23a09968db875371576.jpg@160w_220h_1e_1c", "title": "風之谷", "actor": "島本須美,永井一郎,坂本千夏", "time": "1992", "score": "8.9"} {"index": "42", "image": "https://p1.meituan.net/movie/d5e5e53ef9bbd98223e83df261b51b84103223.jpg@160w_220h_1e_1c", "title": "瘋狂原始人", "actor": "尼古拉斯·凱奇,艾瑪·斯通,瑞安·雷諾茲", "time": "2013-04-20", "score": "9.5"} {"index": "43", "image": "https://p1.meituan.net/movie/5896de3c1474277730e321c9b1db04a9205644.jpg@160w_220h_1e_1c", "title": "當幸福來敲門", "actor": "威爾·史密斯,賈登·史密斯,坦迪·牛頓", "time": "2008-01-17", "score": "8.9"} {"index": "44", "image": "https://p0.meituan.net/movie/df15efd261060d3094a73ef679888d4f238149.jpg@160w_220h_1e_1c", "title": "十二怒漢", "actor": "亨利·方達,李·科布,馬丁·鮑爾薩姆", "time": "1957-04-13(美國)", "score": "9.1"} {"index": "45", "image": "https://p1.meituan.net/movie/4a4c84aa103ab47202f1aa907c5542a4128882.jpg@160w_220h_1e_1c", "title": "V字仇殺隊", "actor": "娜塔莉·波特曼,雨果·維文,斯蒂芬·瑞", "time": "2006-03-17(美國)", "score": "8.8"} {"index": "46", "image": "https://p0.meituan.net/movie/7cd18fcf0b4f9180500124711e81492994030.jpg@160w_220h_1e_1c", "title": "放牛班的春天", "actor": "熱拉爾·朱尼奧,讓-巴蒂斯特·莫尼耶,瑪麗·布奈爾", "time": "2004-10-16", "score": "8.8"} {"index": "47", "image": "https://p0.meituan.net/movie/4bb144bc0a674ba6908349018fd092e6330929.jpg@160w_220h_1e_1c", "title": "三傻大鬧寶萊塢", "actor": "阿米爾·汗,黃渤,卡琳娜·卡普", "time": "2011-12-08", "score": "9.1"} {"index": "48", "image": "https://p1.meituan.net/movie/f8e9d5a90224746d15dfdbd53d4fae3d209420.jpg@160w_220h_1e_1c", "title": "勇敢的心", "actor": "梅爾·吉布森,蘇菲·瑪索,帕特里克·麥高漢", "time": "1995-05-24(美國)", "score": "8.8"} {"index": "49", "image": "https://p1.meituan.net/movie/5ca6ffcbb994a51cd6215e7c4fff2d9b71039.jpg@160w_220h_1e_1c", "title": "黑客帝國3:矩陣革命", "actor": "基努·里維斯,雨果·維文,凱瑞-安·莫斯", "time": "2003-11-05", "score": "8.8"} {"index": "50", "image": "https://p1.meituan.net/movie/1d0fa86bcf7a44484b9c16ac6af5be68191952.jpg@160w_220h_1e_1c", "title": "速度與激情5", "actor": "范·迪塞爾,保羅·沃克,道恩·強森", "time": "2011-05-12", "score": "9.2"} {"index": "51", "image": "https://p1.meituan.net/movie/8194ae885ed9419aadf35c196af86ba4239039.jpg@160w_220h_1e_1c", "title": "馴龍高手", "actor": "杰伊·巴魯切爾,杰拉德·巴特勒,亞美莉卡·費雷拉", "time": "2010-05-14", "score": "9.0"} {"index": "52", "image": "https://p0.meituan.net/movie/85c2bfba6025bfbfb53291ae5924c215308805.jpg@160w_220h_1e_1c", "title": "神偷奶爸", "actor": "史蒂夫·卡瑞爾,杰森·席格爾,拉塞爾·布蘭德", "time": "2010-07-09(美國)", "score": "9.0"} {"index": "53", "image": "https://p0.meituan.net/movie/34998e31c6d07475f1add6b8b16fd21d192579.jpg@160w_220h_1e_1c", "title": "少年派的奇幻漂流", "actor": "蘇拉·沙瑪,伊爾凡·可汗,塔布", "time": "2012-11-22", "score": "9.1"} {"index": "54", "image": "https://p0.meituan.net/movie/7cb7965469cb7ff95613714389f1ea3d87743.jpg@160w_220h_1e_1c", "title": "聞香識女人", "actor": "阿爾·帕西諾,克里斯·奧唐納,加布里埃爾·安瓦爾", "time": "1992-12-23(美國)", "score": "8.8"} {"index": "55", "image": "https://p0.meituan.net/movie/e71affe126eeb4f8bfcc738cbddeebc8288766.jpg@160w_220h_1e_1c", "title": "斷背山", "actor": "希斯·萊杰,杰克·吉倫哈爾,米歇爾·威廉姆斯", "time": "2006-01-13(美國)", "score": "9.0"} {"index": "56", "image": "https://p0.meituan.net/movie/47dd790e19dad72b50580641de5608c5199014.jpg@160w_220h_1e_1c", "title": "飛屋環游記", "actor": "愛德華·阿斯納,喬丹·長井,鮑勃·彼德森", "time": "2009-08-04", "score": "8.9"} {"index": "57", "image": "https://p0.meituan.net/movie/92eb862c42c49f8e41e459c369c4512b226610.jpg@160w_220h_1e_1c", "title": "大話西游之月光寶盒", "actor": "周星馳,莫文蔚,吳孟達", "time": "2014-10-24", "score": "9.6"} {"index": "58", "image": "https://p1.meituan.net/movie/4dddd98730274c3b1464ff0a0ad195e5233381.jpg@160w_220h_1e_1c", "title": "飛越瘋人院", "actor": "杰克·尼科爾森,路易絲·弗萊徹,威爾·薩姆森", "time": "1975-11-19(美國)", "score": "8.8"} {"index": "59", "image": "https://p0.meituan.net/movie/457a35fda360cb72090fa6dcbd1db3c1275333.jpg@160w_220h_1e_1c", "title": "怦然心動", "actor": "瑪德琳·卡羅爾,卡蘭·麥克奧利菲,艾丹·奎因", "time": "2010-08-06(美國)", "score": "8.9"} {"index": "60", "image": "https://p1.meituan.net/movie/92198a6fc8c3f5d13aa1bdf203572c0f99438.jpg@160w_220h_1e_1c", "title": "美國往事", "actor": "羅伯特·德尼羅,詹姆斯·伍茲,伊麗莎白·麥戈文", "time": "1984-02-17(美國)", "score": "9.1"} {"index": "61", "image": "https://p1.meituan.net/movie/75c0d3eb584be030a01f2e26741a8f41251454.jpg@160w_220h_1e_1c", "title": "致命魔術", "actor": "休·杰克曼,克里斯蒂安·貝爾,邁克爾·凱恩", "time": "2006-10-20(美國)", "score": "8.8"} {"index": "62", "image": "https://p1.meituan.net/movie/0b507aa44c4dfbbcc91949b69b1b39a168922.jpg@160w_220h_1e_1c", "title": "鬼子來了", "actor": "姜文,姜宏波,陳強", "time": "2000-05-12(法國戛納)", "score": "8.9"} {"index": "63", "image": "https://p0.meituan.net/movie/fcc17667b8343131101eeb4c67d90bf9150883.jpg@160w_220h_1e_1c", "title": "無敵破壞王", "actor": "約翰·C·賴利,薩拉·西爾弗曼,簡·林奇", "time": "2012-11-06", "score": "9.1"} {"index": "64", "image": "https://p0.meituan.net/movie/7b7d1f8aa36d7a15463ce6942708a1a7265296.jpg@160w_220h_1e_1c", "title": "美麗心靈", "actor": "羅素·克洛,詹妮弗·康納利,艾德·哈里斯", "time": "2001-12-21(美國)", "score": "8.8"} {"index": "65", "image": "https://p1.meituan.net/movie/96bb58f3e9d213fb0438987d16d27561379209.jpg@160w_220h_1e_1c", "title": "蝙蝠俠:黑暗騎士崛起", "actor": "克里斯蒂安·貝爾,邁克爾·凱恩,加里·奧德曼", "time": "2012-08-27", "score": "8.9"} {"index": "66", "image": "https://p0.meituan.net/movie/7ec873ba943f13e3c63789d899bd0e23256871.jpg@160w_220h_1e_1c", "title": "夜訪吸血鬼", "actor": "湯姆·克魯斯,布拉德·皮特,克爾斯滕·鄧斯特", "time": "1994-11-11(美國)", "score": "8.8"} {"index": "67", "image": "https://p1.meituan.net/movie/6d0510f326bf145dcf49a901fb949b77278838.jpg@160w_220h_1e_1c", "title": "倩女幽魂", "actor": "張國榮,王祖賢,午馬", "time": "2011-04-30", "score": "9.2"} {"index": "68", "image": "https://p1.meituan.net/movie/68fa7db99e958c47d7aa07d015845a6f335154.jpg@160w_220h_1e_1c", "title": "哈利·波特與死亡圣器(下)", "actor": "丹尼爾·雷德克里夫,魯伯特·格林特,艾瑪·沃特森", "time": "2011-08-04", "score": "9.0"} {"index": "69", "image": "https://p0.meituan.net/movie/2526f77c650bf7cf3d5ee2dccdeac332244951.jpg@160w_220h_1e_1c", "title": "本杰明·巴頓奇事", "actor": "布拉德·皮特,凱特·布蘭切特,塔拉吉·P·漢森", "time": "2008-12-25(美國)", "score": "8.8"} {"index": "70", "image": "https://p1.meituan.net/movie/484171372de45945e8bbbcc97db57e09136701.jpg@160w_220h_1e_1c", "title": "鋼琴家", "actor": "艾德里安·布洛迪,艾米莉婭·福克斯,米哈烏·熱布羅夫斯基", "time": "2002-09-25(法國)", "score": "8.8"} {"index": "71", "image": "https://p0.meituan.net/movie/7874ba1378033b0b491df0cc56c43d25221208.jpg@160w_220h_1e_1c", "title": "觸不可及", "actor": "弗朗索瓦·克魯塞,奧瑪·希,安娜·勒尼", "time": "2011-11-02(法國)", "score": "9.1"} {"index": "72", "image": "https://p1.meituan.net/movie/4ad513be2e9419ec7d7d63ba8cc2b6cc134065.jpg@160w_220h_1e_1c", "title": "熔爐", "actor": "孔劉,鄭有美,金智英", "time": "2011-09-22(韓國)", "score": "8.8"} {"index": "73", "image": "https://p1.meituan.net/movie/7ed07b8ea8c0e0d0c7b685d20e3ec64e232004.jpg@160w_220h_1e_1c", "title": "初戀這件小事", "actor": "馬里奧·毛瑞爾,平采娜·樂維瑟派布恩,阿查拉那·阿瑞亞衛考", "time": "2012-06-05", "score": "8.8"} {"index": "74", "image": "https://p1.meituan.net/movie/dc2246233a6f5ac1e34c7176b602c8ca174557.jpg@160w_220h_1e_1c", "title": "大話西游之大圣娶親", "actor": "周星馳,朱茵,莫文蔚", "time": "2014-10-24", "score": "8.8"} {"index": "75", "image": "https://p0.meituan.net/movie/9e9f12cfc1f54c973dda6c85bd3a139d334520.jpg@160w_220h_1e_1c", "title": "新龍門客棧", "actor": "張曼玉,梁家輝,甄子丹", "time": "2012-02-24", "score": "8.8"} {"index": "76", "image": "https://p1.meituan.net/movie/8ad5a0f521fb15637dfdf9cab38d414453783.jpg@160w_220h_1e_1c", "title": "甜蜜蜜", "actor": "黎明,張曼玉,曾志偉", "time": "2015-02-13", "score": "9.2"} {"index": "77", "image": "https://p0.meituan.net/movie/4cc4c55c29b77b090485ce9943bf6f87274708.jpg@160w_220h_1e_1c", "title": "素媛", "actor": "李來,薛耿求,嚴志媛", "time": "2013-10-02(韓國)", "score": "9.1"} {"index": "78", "image": "https://p1.meituan.net/movie/bc7b6ababa54e11577d45c05e84a33af54072.jpg@160w_220h_1e_1c", "title": "小鞋子", "actor": "默罕默德·阿米爾·納吉,Kamal Mirkarimi,Behzad Rafi", "time": "1999-01-22(美國)", "score": "9.1"} {"index": "79", "image": "https://p0.meituan.net/movie/5420be40e3b755ffe04779b9b199e935256906.jpg@160w_220h_1e_1c", "title": "螢火之森", "actor": "內山昂輝,佐倉綾音,后藤弘樹", "time": "2011-09-17(日本)", "score": "9.0"} {"index": "80", "image": "https://p0.meituan.net/movie/4abc8c932cfacfc0089e2883765d02d1295222.jpg@160w_220h_1e_1c", "title": "時空戀旅人", "actor": "瑞秋·麥克亞當斯,多姆納爾·格里森,比爾·奈伊", "time": "2013-09-04(英國)", "score": "8.9"} {"index": "81", "image": "https://p1.meituan.net/movie/a0e0426a4390f5ecb49d25770a184dc0150779.jpg@160w_220h_1e_1c", "title": "穿條紋睡衣的男孩", "actor": "阿沙·巴特菲爾德,維拉·法梅加,大衛·休里斯", "time": "2008-09-12(英國)", "score": "9.0"} {"index": "82", "image": "https://p0.meituan.net/movie/3985eaf3858bea0f2a3d966bf7ee2103178217.jpg@160w_220h_1e_1c", "title": "竊聽風暴", "actor": "烏爾里希·穆埃,塞巴斯蒂安·科赫,馬蒂娜·格德克", "time": "2006-03-23(德國)", "score": "9.0"} {"index": "83", "image": "https://p1.meituan.net/movie/6a6e74b2c289f9fa4433dd2dc04a7741331638.jpg@160w_220h_1e_1c", "title": "7號房的禮物", "actor": "柳承龍,鄭鎮榮,樸信惠", "time": "2013-01-23(韓國)", "score": "8.9"} {"index": "84", "image": "https://p0.meituan.net/movie/ce262f261f69fc3d679020402336a4af270365.jpg@160w_220h_1e_1c", "title": "借東西的小人阿莉埃蒂", "actor": "志田未來,神木隆之介,大竹忍", "time": "2010-07-17(日本)", "score": "8.8"} {"index": "85", "image": "https://p0.meituan.net/movie/b5ff0216e689b3fcc065590c48cd5105255305.jpg@160w_220h_1e_1c", "title": "恐怖直播", "actor": "河正宇,李璟榮,李大為", "time": "2013-07-31(韓國)", "score": "8.8"} {"index": "86", "image": "https://p0.meituan.net/movie/7373dbba07b50ce6f24336edb96b2ea4271536.jpg@160w_220h_1e_1c", "title": "海豚灣", "actor": "里克·奧巴瑞,路易·西霍尤斯,哈迪·瓊斯", "time": "2009-07-31(美國)", "score": "8.9"} {"index": "87", "image": "https://p1.meituan.net/movie/c835b3588d0061ed3b992388a0a96f15160913.jpg@160w_220h_1e_1c", "title": "忠犬八公物語", "actor": "仲代達矢,春川真澄,井川比佐志", "time": "1987-08-01(日本)", "score": "9.0"} {"index": "88", "image": "https://p1.meituan.net/movie/b553d13f30100db731ab6cf45668e52d94703.jpg@160w_220h_1e_1c", "title": "上帝之城", "actor": "亞歷桑德雷·羅德里格斯,艾莉絲·布拉加,萊安德魯·菲爾米諾", "time": "2002-08-30(巴西)", "score": "8.9"} {"index": "89", "image": "https://p0.meituan.net/movie/8fabf3894b7d12d3d2f6e66404813670265761.jpg@160w_220h_1e_1c", "title": "辯護人", "actor": "宋康昊,郭度沅,吳達洙", "time": "2013-12-18(韓國)", "score": "8.8"} {"index": "90", "image": "https://p1.meituan.net/movie/73349facab53529ab9e079c6c8c7c059281729.jpg@160w_220h_1e_1c", "title": "七武士", "actor": "三船敏郎,志村喬,千秋實", "time": "1954-04-26(日本)", "score": "9.1"} {"index": "91", "image": "https://p0.meituan.net/movie/3e5f5f3aa4b7e5576521e26c2c7c894d253975.jpg@160w_220h_1e_1c", "title": "英雄本色", "actor": "狄龍,張國榮,周潤發", "time": "2017-11-17", "score": "9.2"} {"index": "92", "image": "https://p1.meituan.net/movie/2c0a5fedf4b43d142121b91c6ccabe1b59051.jpg@160w_220h_1e_1c", "title": "一一", "actor": "吳念真,金燕玲,李凱莉", "time": "2000-09-20(法國)", "score": "8.9"} {"index": "93", "image": "https://p1.meituan.net/movie/30310858fdab34c7a17cfd7ec8ad8bfc112201.jpg@160w_220h_1e_1c", "title": "完美的世界", "actor": "凱文·科斯特納,克林特·伊斯特伍德,T·J·勞瑟", "time": "1993-11-24(美國)", "score": "8.9"} {"index": "94", "image": "https://p1.meituan.net/movie/36a893c53a13f9bb934071b86ae3b5c492427.jpg@160w_220h_1e_1c", "title": "愛·回家", "actor": "俞承豪,金藝芬,童孝熙", "time": "2002-04-05(韓國)", "score": "9.0"} {"index": "95", "image": "https://p0.meituan.net/movie/0018b57299d0d4540330a31244c880a9112971.jpg@160w_220h_1e_1c", "title": "海洋", "actor": "雅克·貝漢,姜文,蘭斯洛特·佩林", "time": "2011-08-12", "score": "9.0"} {"index": "96", "image": "https://p1.meituan.net/movie/9bff56ed3ea38bb1825daa1d354bc92352781.jpg@160w_220h_1e_1c", "title": "黃金三鏢客", "actor": "克林特·伊斯特伍德,李·范·克里夫,埃里·瓦拉赫", "time": "1966-12-23(意大利)", "score": "8.9"} {"index": "97", "image": "https://p1.meituan.net/movie/ed50b58bf636d207c56989872a91f4cf305138.jpg@160w_220h_1e_1c", "title": "我愛你", "actor": "宋在浩,李順才,尹秀晶", "time": "2011-02-17(韓國)", "score": "9.0"} {"index": "98", "image": "https://p1.meituan.net/movie/a1634f4e49c8517ae0a3e4adcac6b0dc43994.jpg@160w_220h_1e_1c", "title": "遷徙的鳥", "actor": "雅克·貝漢,Philippe Labro", "time": "2001-12-12(法國)", "score": "9.1"} {"index": "99", "image": "https://p0.meituan.net/movie/885fc379c614a2b4175587b95ac98eb95045650.jpg@160w_220h_1e_1c", "title": "阿飛正傳", "actor": "張國榮,張曼玉,劉德華", "time": "2018-06-25", "score": "8.8"} {"index": "100", "image": "https://p0.meituan.net/movie/c304c687e287c7c2f9e22cf78257872d277201.jpg@160w_220h_1e_1c", "title": "龍貓", "actor": "帕特·卡洛爾,蒂姆·達利,麗婭·薩隆加", "time": "2018-12-14", "score": "9.2"}結果的每一行都是一個字典類型,這樣我們就得到了top100d的電影信息,本期的的難點在于正則表達式的構造,在進行匹配時,最好使用非貪婪模式,而且將我們需要獲取到的內容用()的形式括起來,這樣便能夠得到我們想要的內容。
總結
以上是生活随笔為你收集整理的网络爬虫学习(十二)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Protel99SE教程(一)——原理图
- 下一篇: 排队论的计算机模拟,系统容量有限的一类排