西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
西西首頁(yè) 電腦軟件 安卓軟件 電腦游戲 安卓游戲 排行榜 專題合集

python爬取半次元圖片源碼

  • python爬取半次元圖片源碼
  • 軟件大小:1KB
  • 更新時(shí)間:2019-07-24 16:41
  • 軟件語(yǔ)言:中文
  • 軟件廠商:
  • 軟件類別:國(guó)產(chǎn)軟件 / 免費(fèi)軟件 / 源碼相關(guān)
  • 軟件等級(jí):3級(jí)
  • 應(yīng)用平臺(tái):WinXP, Win7, win8
  • 官方網(wǎng)站:暫無(wú)
  • 應(yīng)用備案:
好評(píng):50%
壞評(píng):50%

本類精品

軟件介紹

python爬取半次元圖片源碼,由大神自制的python爬取工具,本源碼針對(duì)半次元圖片平臺(tái),可以爬取最新的網(wǎng)站圖片資源,支持自定義保存目錄,非常方便,需要requests庫(kù)的支持,想要相關(guān)源碼資源的朋友們不要錯(cuò)過(guò)哦!

python爬取半次元圖片源碼

python爬取半次元圖片源碼說(shuō)明:

需要安裝requests庫(kù),在運(yùn)行腳本的文件夾下新建一個(gè)img文件夾

源碼也可供大家學(xué)習(xí)和參考。

python爬取半次元圖片源碼一覽:

import requests

import re

url = 'https://bcy.net/coser/toppost100'  # 要進(jìn)行抓取的url

web_url = "https://bcy.net"  # 官方網(wǎng)站

file = 'img/'  # 文件的保存路徑最后加反斜杠

headers = {

    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'

}

# 獲取抓取數(shù)據(jù)頁(yè)面

data = requests.get(url, headers=headers).text

wi_url_id = re.findall('<a href=".*?class="db posr ovf"', data)

# 對(duì)抓取圖片單獨(dú)頁(yè)面url進(jìn)行遍歷

for s in wi_url_id:

    wi_id = web_url + s.lstrip('<a href="').rstrip('" class="db posr ovf"')

    n_data = requests.get(wi_id, headers=headers).text  # 獲取單獨(dú)的圖片頁(yè)面數(shù)據(jù)

    json_data = re.findall('"{.*?}"', n_data)[0].lstrip('"').rstrip('}}"')

    n_http = re.findall('"path.*?w650', json_data)

    # 對(duì)圖片url進(jìn)行遍歷

    for b in n_http:

        try:

            img_data = b.lstrip('"path\\":\\"s') + '.image'

            img_url = 'https:/' + img_data.replace('u002F', '').replace('\\\\', '/')

            img = requests.get(img_url, headers=headers).content  # 獲取圖片數(shù)據(jù)

            img_name = img_url.rstrip('.jpg~tplv-banciyuan-w650.image')[-31:]  # 獲取圖片名

            # 對(duì)圖片進(jìn)行保存

            with open(file + img_name + '.jpg', 'wb') as f:

                f.write(img)

                print('以保存,圖片url:' + img_url)

        except:

            print('保存失敗')

python爬取相關(guān)視頻:

其他版本下載

發(fā)表評(píng)論

昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
查看所有(0)條評(píng)論 > 字?jǐn)?shù): 0/500

TOP
軟件下載