91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

適合爬蟲初學者的必備入門demo,效果如下:

要求環境python3.7,安裝庫

requests,xlwt,re,os
采用新手友好的原始正則對文本進行篩選,爬取豆瓣top250電影信息,生成excel表格,可在pycharm中直接運行,
默認保存目錄D:/test

資源截圖

代碼片段和文件信息

import?requests
import?xlwt
import?re
import?os
#保存數據生成excel表格
def?save_date(datalistsavepath):
?????if?not?os.path.exists(savepath):
?????????print(‘未存在文件夾‘savepath‘創建中‘)
?????????os.makedirs(savepath)
?????else:
?????????print(‘已存在文件夾,保存中‘)
?????savepath=savepath+‘/豆瓣top250電影.xls‘
?????book=xlwt.Workbook(encoding=‘utf-8‘style_compression=0)
?????sheet=book.add_sheet(“豆瓣電影Top248“cell_overwrite_ok=True)
?????col=(‘排名‘‘名稱‘‘詳細信息‘‘評分‘‘介紹‘)
?????for?i?in?range(05):
?????????sheet.write(0icol[i])
?????for?i?in?range(0len(datalist)):
??????????sheet.write(i+10datalist[i].get(‘index‘))
??????????sheet.write(i+1?1?datalist[i].get(‘title‘))
??????????sheet.write(i+1?2?datalist[i].get(‘info‘))
??????????sheet.write(i+1?3?datalist[i].get(‘score‘))
?????????

評論

共有 條評論