该项目已停止维护。其衍生项目为【豆瓣魂组数据镜像】。
本仓库的源代码的默认分支【mobileAPI】并不完善,尽管完成了六成的功能代码,带并没有将它们成熟地组织起来。
原始的枝江存档姬源码请查阅分支【main】。
wendaolee / doubansaver Goto Github PK
View Code? Open in Web Editor NEW枝江存档姬源代码
枝江存档姬源代码
该项目已停止维护。其衍生项目为【豆瓣魂组数据镜像】。
本仓库的源代码的默认分支【mobileAPI】并不完善,尽管完成了六成的功能代码,带并没有将它们成熟地组织起来。
原始的枝江存档姬源码请查阅分支【main】。
目前偶尔会因为API的mail lock导致查询时出现错误。
等到之后有空添加这一部分报错的逻辑处理。预计返回一个几秒后刷新原页面的404页面。
import asyncio
import aiohttp
import hmac
import base64
import time
from urllib.parse import urlparse, quote, urlencode
headers = {
"User-Agent": "api-client/1 com.douban.frodo/7.27.0.6(231) Android/25 product/DT1901A vendor/smartisan model/DT1901A brand/smartisan rom/android network/wifi udid/5fe86d1e414d8417ff3ec84c369e28c97a7d9d45 platform/AndroidPad",
}
dm = {
"channel": "Douban",
"os_rom": "android",
}
def encrypt(api, method, data):
path = urlparse(api).path
secret = b"bf7dddc7c9cfe6f7"
timestamp = int(time.time())
message = ("&".join([method, quote(path, safe=""), str(timestamp)]))
h = hmac.new(secret, message.encode(), digestmod="sha1")
b = base64.b64encode(h.digest())
return {
**data,
"apikey": "0dad551ec0f84ed02907ff5c42e8ec70",
"_ts": timestamp,
"_sig": b.decode(),
}
# 生成签名函数
async def get(api, params=None):
async with aiohttp.ClientSession() as session:
async with session.get(api, params=params, headers=headers) as resp:
data = await resp.json()
return data
async def getTopic(tid):
api = "https://frodo.douban.com/api/v2/group/topic/{}".format(tid)
params = encrypt(api, "GET", dm)
return await get(api, params)
# 获取主贴内容
async def getComment(tid, start=0, count=20):
api = "https://frodo.douban.com/api/v2/group/topic/{}/comments".format(tid)
params = encrypt(api, "GET", {**dm, "start": start, "count": count})
return await get(api, params)
# 获取评论(一次最多20条)
async def getAllComments(tid):
comments = []
i = 0
r = await getComment(tid)
while r["comments"]:
i += 20
comments += r["comments"]
r = await getComment(tid, i)
print(i)
await asyncio.sleep(0.5)
return comments
# 获取全部评论
仅供参考
http://asoul.otterdaily.cn:9000/api/getmailInfo/1
比如这个接口,返回的是整个html的字符串,希望可以用beautifulsoap处理一下变成比较好处理的格式
目前在豆瓣发生服务器崩溃的情况下,存档姬会发生宕机。
之后需要添加手动备份的功能。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.