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

  • 大小: 3KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-21
  • 語言: Python
  • 標簽: python??

資源簡介

一加云相冊批量下載爬蟲,腳本用python編寫。使用時需要先在chrome瀏覽器中登錄一加云相冊(cloud.h2os.com)。

資源截圖

代碼片段和文件信息



import?browsercookie
import?requests
import?json
import?time
import?random
import?os.path
from?requests.packages?import?urllib3

#?一加云服務圖片批量下載爬蟲
#?by?鏡亦

headers?=?{
????“User-Agent“:?“Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/73.0.3683.103?Safari/537.36“}
cookies?=?None
lastIndex?=?0
cursor?=?“not?attained“

#?消除?warning???InsecureRequestWarning
urllib3.disable_warnings()

#?獲取cookie,前提是需要瀏覽器登陸過


def?getCookies():
????global?cookies
????if?cookies?==?None:
????????cookies?=?requests.utils.dict_from_cookiejar(browsercookie.chrome())
????mcookies?=?requests.utils.cookiejar_from_dict(
????????cookies?cookiejar=None?overwrite=True)
????return?mcookies


def?getPhotoList():
????global?lastIndex?cursor?cookies
????postUrl?=?“https://cloud.h2os.com/gallery/pc/listNormalPhotos“
????response?=?requests.post(postUrl?generateForm(
????????lastIndex?cursor)?cookies=getCookies()?headers=headers)
????cookies?=?dict(
????????cookies?**requests.utils.dict_from_cookiejar(response.cookies))
????jResult?=?json.loads(response.text)
????print(“LastIndex?:?“+str(lastIndex)+“??Cursor?:?“?+?str(cursor))
????try:
????????print(“Result?:?“?+?str(jResult[“errCode“])?+?“?“?+?jResult[‘errMsg‘])
????except?Exception:
????????print(“發生錯誤:\n“?+?response.text)
????????exit(1)
????lastIndex?=?jResult[“realPhotoIndex“]
????cursor?=?jResult[“lastMatchedMoment“]
????return?jResult[“photos“]


def?downloadImage(FullPath?fileName?url):
????global?cookies
????nameWithPath?=?FullPath?+?“\\“?+?fileName
????if?os.path.exists(nameWithPath):
????????print(“already?exixt?:?“+fileName)
????????return
????print(“Do

評論

共有 條評論