国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運營 > 原來制作一個漫畫網(wǎng)站這么簡單!!!!!

原來制作一個漫畫網(wǎng)站這么簡單!!!!!

時間:2023-07-23 00:00:02 | 來源:網(wǎng)站運營

時間:2023-07-23 00:00:02 來源:網(wǎng)站運營

原來制作一個漫畫網(wǎng)站這么簡單!!!!!:

?原來制作一個漫畫網(wǎng)站這么簡單!!!!!

制作一個漫畫網(wǎng)站的流程是什么?

獲取漫畫數(shù)據(jù)

第一步必然是要獲取到漫畫數(shù)據(jù),漫畫平臺可以說數(shù)不勝數(shù),騰訊漫畫,漫畫臺,咚漫漫畫等等,所以我們要獲取數(shù)據(jù)必然也是從這些平臺去獲取,這里就隨便從一個漫畫平臺去分析獲取漫畫數(shù)據(jù).

爬取網(wǎng)站四部曲

分析

我們以爬取比較熱門的動漫--->妖神記

請?zhí)砑訄D片描述



我們先隨便進入一話




在這里插入圖片描述



先打開控制臺,第一時間查看請求,先判斷我們需要的數(shù)據(jù)是通過Fetch/XHR還是文檔直接生成的,通過這樣去判斷我們寫腳本的方式是直接通過獲取數(shù)據(jù)還是用xml去定位數(shù)據(jù)并獲取




在這里插入圖片描述
在這里插入圖片描述



查看這個請求里面的參數(shù)和返回結(jié)果,尋找是否有我們想要的數(shù)據(jù)




在這里插入圖片描述



用postman直接測試接口,查看是否需要cookie或者其他的header

在這里插入圖片描述



可以看到并不需要任何其他條件(這樣就簡單了)

問題

參數(shù)有哪些變化,我們可以對比第一話和第二話的請求參數(shù)

在這里插入圖片描述



很明顯主要差別在于chapter_newid,那這個參數(shù)怎么獲得,我們其實看看第一話和第二話的請求結(jié)果就會發(fā)現(xiàn)到這個參數(shù)




在這里插入圖片描述



所以我們可以通過第一話就直接獲得下一話參數(shù),這樣我們就可以開始寫代碼了

代碼實現(xiàn)

import osimport requestsfrom PIL import Imagefrom io import BytesIOdef MergeImage(width, height, imgList, save_img): # -----create a new image-----# img = Image.new("RGB", (width, height), (0, 0, 0)) h = 0 for iimg in imgList: img.paste(iimg, (0, h)) h += iimg.size[1] img.save(save_img) print("保存成功")def saveComic(splitComic): headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53", "Referer": "https://www.manhuatai.com/", "Accept": "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8", } chapter_newid = "dyhzs" while True: params = { "product_id": 2, "productname": "mht", "platformname": "pc", "comic_id": 27417, "chapter_newid": chapter_newid, "isWebp": 1, "quality": "middle" } url = "https://www.manhuatai.com/api/getchapterinfov2" # 請求漫畫api resp = requests.get(url=url, params=params, headers=headers).json() # 獲取標題 chapter_name = resp['data']['current_chapter']['chapter_name'] # 獲取當前話的圖片列表 chapter_img_list = resp['data']['current_chapter']['chapter_img_list'] # 獲取目錄名 dirName = f"./result/{resp['data']['comic_name']}" # 判斷目錄是否存在,不存在則創(chuàng)建目錄 if not os.path.exists(dirName): os.mkdir(dirName) index = 1 imgList = [] maxWidth = 0 height = 0 for imgUrl in chapter_img_list: content = requests.get(url=imgUrl, headers=headers).content if not splitComic: # 直接將分開的圖片合并在一起 bytes_stream = BytesIO(content) image = Image.open(bytes_stream) imgList.append(image) maxWidth = max(maxWidth, image.size[0]) height += image.size[1] else: # 判斷目錄是否存在,不存在則創(chuàng)建目錄 if not os.path.exists(dirName+"/"+chapter_name): os.mkdir(dirName+"/"+chapter_name) with open(f"{dirName}/{chapter_name}/{chapter_name}{index}.webp",mode="wb") as fs: fs.write(content) index += 1 if not splitComic: MergeImage(maxWidth, height, imgList, f"{dirName}/{chapter_name}.png") # 最后一話直接跳出 if resp['data']['next_chapter']: # 獲取下一話的chapter_newid chapter_newid = resp['data']['next_chapter']['chapter_newid'] next_chapter_name = resp['data']['next_chapter']['chapter_name'] print(f"{chapter_name}已經(jīng)下載完成,即將下載{next_chapter_name},chapter_newid為{chapter_newid}") else: breakif __name__ == '__main__': saveComic(False)


在這里插入圖片描述






在這里插入圖片描述



制作html頁面




請?zhí)砑訄D片描述



想要獲取全部html和python源碼,請關(guān)注公眾號-->愛上開源




在這里插入圖片描述






關(guān)注微信公眾號【愛上開源】,該公眾號會為你提供作者在網(wǎng)上找到有趣的開源項目,會將使用過程寫成文章呈現(xiàn)給讀者.公眾號還提供爬蟲和部分計算機資源給讀者.如果讀者想要什么資源可以私信給我,作者會盡力查詢(不要涉嫌違法資源即可)



關(guān)鍵詞:簡單,漫畫

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點擊下載Chrome瀏覽器
關(guān)閉