国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開(kāi)通VIP
利用Python3爬蟲唯一圖庫(kù)網(wǎng)上的漂亮妹子圖ok

利用Python爬唯一圖庫(kù)網(wǎng)上的漂亮妹子圖

寫在前面

學(xué)習(xí)了很多Python知識(shí),敲寫了千萬(wàn)行代碼,感覺(jué)學(xué)Python語(yǔ)言太枯燥乏味了。但是呢,本著美女是學(xué)習(xí)動(dòng)力的第一原則,啊哈哈。寫個(gè)程序把妹子們都下載下來(lái)吧。
今天咱們就利用Python爬取唯一圖庫(kù)http://www.mmonly.cc/mmtp/)上的漂亮的妹子圖,給大家一波福利。O(∩_∩)O。

福利時(shí)刻

妹子圖片質(zhì)量整體上還是不錯(cuò)呦,放三張不同風(fēng)格的圖大家感受下,O(∩_∩)O哈哈~


爬取結(jié)果

程序框架

import urllib.requestfrom bs4 import BeautifulSoupimport osdef Download(url,picAlt,name):...def run(targetUrl, beginNUM ,endNUM):...    if beginNUM ==endNUM...if __name__ == '__main__':

程序思路

  1. 群定目標(biāo)網(wǎng)站
  2. 提取該網(wǎng)頁(yè)的HTML代碼
  3. 運(yùn)用BeautifulSoup獲取想要的內(nèi)容
  4. 保存數(shù)據(jù)

程序步驟

  • (1)確定目標(biāo)網(wǎng)站:http://www.mmonly.cc/mmtp
  • (2)分析該網(wǎng)頁(yè)的HTML代碼
  • (3)運(yùn)用BeautifulSoup獲取內(nèi)容
  • (4)保存數(shù)據(jù)

程序?qū)崿F(xiàn)

該程序利用Beautiful Soup實(shí)現(xiàn)的,它其實(shí)是Python的一個(gè)庫(kù),主要功能是從網(wǎng)頁(yè)抓取數(shù)據(jù),可參考這篇詳細(xì)文章(https://cuiqingcai.com/1319.html/comment-page-1#comments)
安裝Beautiful Soup

pip install beautiful soup4

導(dǎo)包

from bs4 import BeautifulSoup

建立保存路徑

def Download(url,picAlt,name):    path = 'D:\\pythonD爬蟲妹子圖\\'+picAlt+'\\'    if not os.path.exists(path):        os.makedirs(path)    urllib.request.urlretrieve( url, '{0}{1}.jpg'.format(path, name)) 

完整代碼如下

import urllib.requestfrom bs4 import BeautifulSoupimport os def Download(url,picAlt,name):    path = 'D:\\pythonD爬蟲妹子圖\\'+picAlt+'\\'    if not os.path.exists(path):        os.makedirs(path)    urllib.request.urlretrieve( url, '{0}{1}.jpg'.format(path, name))  header = {    "User-Agent":'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36',    'Accept': '*/*',    'Accept-Language': 'en-US,en;q=0.8',    'Cache-Control': 'max-age=0',    'Connection': 'keep-alive'    }def run(targetUrl, beginNUM ,endNUM):    req = urllib.request.Request(url=targetUrl,headers=header)    response = urllib.request.urlopen(req)    html = response.read().decode('gb2312','ignore')    soup = BeautifulSoup(html, 'html.parser')    Divs = soup.find_all('div',attrs={'id':'big-pic' })    nowpage = soup.find('span',attrs={'class':'nowpage'}).get_text()    totalpage= soup.find('span',attrs={'class':'totalpage'}).get_text()    if beginNUM ==endNUM :        return    for div in Divs:        beginNUM = beginNUM+1         if div.find("a") is None :            print("沒(méi)有下一張了")            return        elif div.find("a")['href'] is None or div.find("a")['href']=="":            print("沒(méi)有下一張了None")            return        print("下載信息:總進(jìn)度:",beginNUM,"/",endNUM," ,正在下載套圖:(",nowpage,"/",totalpage,")")         if int(nowpage)<int(totalpage):            nextPageLink ="http://www.mmonly.cc/mmtp/qcmn/" +(div.find('a')['href'])        elif int(nowpage)==int(totalpage):            nextPageLink = (div.find('a')['href'])         picLink = (div.find('a').find('img')['src'])        picAlt = (div.find('a').find('img'))['alt']        print('下載的圖片鏈接:',picLink)        print('套圖名:[ ', picAlt , ' ] ')        print('開(kāi)始下載...........')        Download(picLink,picAlt, nowpage)        print("下載成功!")        print('下一頁(yè)鏈接:',nextPageLink)        run(nextPageLink,beginNUM ,endNUM)        return if __name__ == '__main__':    targetUrl ="http://www.mmonly.cc/mmtp/qcmn/237269.html"    run(targetUrl,beginNUM=0,endNUM=70)    print(" OVER")    
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
小白學(xué) Python 爬蟲(16):urllib 實(shí)戰(zhàn)之爬取妹子圖
python爬蟲系列(1)——一個(gè)簡(jiǎn)單的爬蟲實(shí)例
[原創(chuàng)]用Python從四大期貨交易所爬取數(shù)據(jù)[by lianzhang]
python自測(cè)100題(下)
python爬蟲實(shí)踐之網(wǎng)頁(yè)抓取 | IT癮
零基礎(chǔ)寫python爬蟲之爬蟲編寫全記錄
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服