python爬虫登录到海康相机管理页面

简述

1.最近接到个任务是在管理页面更改相机的某个参数,下载官方的sdk貌似没有提供这个接口,所以只能自己写爬虫登录发请求了。

1.主要步骤

1.1 发送get请求获取到salt,sessionID,challenge等信息

http://admin:123456@192.168.1.80/ISAPI/Security/sessionLogin/capabilities?username=admin

1.2 再次发送这个请求,这次要带上一个随机数random。random生成规则如下:

timestamp = str(int(time.time()))

md5_hash = hashlib.md5(timestamp.encode()).hexdigest()

md5_substring = md5_hash[:8].replace("#", "")

result = str(int(md5_substring, 16))[:8]

url += "&random=" + result

print(url)

1.3 最后拿到第二次获得到salt,sessionId,challenge信息和加密的登录密码登录

http://192.168.1.80/ISAPI/Security/sessionLogin?timeStamp=

1.4 问题注意

复制代码
有个特别恶心的问题是requests的post库会转义尖括号。

使用来去除

unescaped_string = urllib.parse.unquote(validation)

最后成功的登录截图:

ps:有需要源码的私信我

相关推荐
明知道的博客21 小时前
解决WSL环境下DeepSeek-OCR运行时内存不足问题
python·ocr·deepseek·deepseek-ocr
q***T5831 天前
MySQL爬虫
数据库·爬虫·mysql
木子杳衫1 天前
【爬虫项目】大众点评电影数据爬虫实战
爬虫
FreeCode1 天前
LangGraph1.0智能体开发:Graph API概念与设计
python·langchain·agent
test管家1 天前
如何在Python中使用SQLite数据库进行增删改查操作?
python
yangmf20401 天前
APM(三):监控 Python 服务链
大数据·运维·开发语言·python·elk·elasticsearch·搜索引擎
yangmf20401 天前
APM(二):监控 Python 服务
大数据·python·elasticsearch·搜索引擎
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2025-11-23)
python·开源·github·mcp
AI爱好者1 天前
WordPress保卫战:用Python分析日志并封禁恶意爬虫
python
nvd111 天前
Gidgethub 使用指南
开发语言·python