资源简介
一加云相册批量下载爬虫,脚本用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
- 上一篇:prepro.py
- 下一篇:freesmallgames.zip
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论