網(wǎng)站性能檢測(cè)評(píng)分
注:本網(wǎng)站頁面html檢測(cè)工具掃描網(wǎng)站中存在的基本問題,僅供參考。
python有多強(qiáng)大
Python大牛分分鐘成功爬取電影天堂網(wǎng)站!厲害了!「附源碼」 企業(yè)視頻課程
準(zhǔn)備工具:requests與xpath
思路:獲取爬取入口,后面的工作就容易多了。我通過測(cè)試發(fā)現(xiàn)這幾個(gè)欄目除了頁面的 url地址不一樣之外,提取信息的xpath路徑是一樣的!所以,我們把五個(gè)欄目當(dāng)做一個(gè)類,然后該類進(jìn)行遍歷爬??!
2.2爬蟲構(gòu)架的設(shè)計(jì)
2.3代碼
#截止到2017-08-08,最新電影一共才有 164個(gè)頁面LASTEST_MOIVE_TOTAL_SUM = 6 #164#請(qǐng)求網(wǎng)絡(luò)線程總數(shù),線程不要調(diào)太好,不然會(huì)返回很多 400THREAD_SUM = 5def startSpider: #實(shí)例化對(duì)象 #獲取【最新電影】有多少個(gè)頁面 LASTEST_MOIVE_TOTAL_SUM = dytt_Lastest.getMaxsize print('【最新電影】一共 ' + str(LASTEST_MOIVE_TOTAL_SUM) + '有個(gè)頁面') dyttlastest = dytt_Lastest(LASTEST_MOIVE_TOTAL_SUM) floorlist = dyttlastest.getPageUrlList floorQueue = TaskQueue.getFloorQueue for item in floorlist: floorQueue.put(item, 3) # print(floorQueue.qsize) for i in range(THREAD_SUM): workthread = FloorWorkThread(floorQueue, i) workthread.start while True: if TaskQueue.isFloorQueueEmpty: break else: pass
源碼:
強(qiáng)大的Python:完全用Python工作 互聯(lián)網(wǎng)視頻課程
主要內(nèi)容:
1.代碼簡(jiǎn)潔性和可讀性2.Python的思想3.Python的類庫齊全
下載:http://51testing/html/54/n-3720754.html