Delphi百度网盘真实地址解析
本文整理自网络,侵删。
写在前边
这里用Delphi演示下获取百度网盘的真实地址,里面一些参数拼接是根据浏览器抓包来的。这里给出了部分源码。
url网址使用于百度分享的地址。暂时没有适配有提取码的地址。
目前,获取
查看更多关于 获取 的文章
到百度网盘真实地址也会限速了,亲测用IDM下载工具最高到600+kb/s
测试环境
Delphi 10.2.3 Tokyo
Windows 7
api地址
var
panUrlRe: string;
begin
try
try
panUrlRe := FIDHttp.Get(panUrl);
sign := GetMidString(panUrlRe, 'sign":"', '",');
timestamp := GetMidString(panUrlRe, 'timestamp":', ',');
app_id := GetMidString(panUrlRe, 'app_id":"', '",');
bdstoken := GetMidString(panUrlRe, 'bdstoken":', ',');
fid_list := GetMidString(panUrlRe, '"fs_id":', ',');
primaryid := GetMidString(panUrlRe, 'shareid":', ',');
uk := GetMidString(panUrlRe, 'uk=', '&');
apiurl := 'https://pan.baidu.com/api/sharedownload?sign=' + sign +
'×tamp=' + timestamp + '&channel=chunlei&web=1' + '&app_id=' +
app_id + '&bdstoken=' + bdstoken;
wa := '1';
end;
except
on e: exception do
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.Memo1.Lines.Add(e.Message);
end);
end;
finally
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.ActivityIndicator1.Animate := False;
end);
end;
获取真实地址
var
VcodUrl: string;
begin
try
try
postinstr := TstringList.Create;
postinstr.Add('encrypt=' + '0');
postinstr.Add('fid_list=[' + fid_list + ']');
postinstr.Add('path_list=');
postinstr.Add('primaryid=' + primaryid);
postinstr.Add('product=' + 'share');
postinstr.Add('uk=' + uk);
postResult := Fidhttp.Post(apiurl, postinstr);
realUrl := StringReplace(GetMidString(postResult, 'dlink":"', '",'), '\',
'', [rfReplaceAll]);
if pos('-20', postResult) > 0 then
begin
VcodUrl :=
'https://pan.baidu.com/api/getvcode?prod=pan&channel=chunlei&web=1&app_id='
+ app_id + '&bdstoken=' + bdstoken;
vcodeRe := Fidhttp.Get(VcodUrl);
vcode_str := GetMidString(vcodeRe, 'vcode":"', '",');
imageUrl := StringReplace(GetMidString(vcodeRe, 'img":"', '"}'), '\',
'', [rfReplaceAll]);
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.ActivityIndicator1.Animate := False;
vcodeForm.ShowModal;
end);
end
else
begin
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.Memo1.Lines.Add('百度真实地址为(8小时有效):' + realUrl);
MainForm.Edit2.Text := realUrl;
end);
IdSSLIOHandlerSocketOpenSSL1.DisposeOf;
Fidhttp.DisposeOf;
end;
except
on e: exception do
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.Memo1.Lines.Add(e.Message);
end);
end;
finally
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.ActivityIndicator1.Animate := False;
MainForm.Button1.Enabled := True;
end);
postinstr.DisposeOf;
end;
end;
下载3次会弹出验证码
var
postinstr2: TstringList;
VcodUrl: string;
begin
try
try
postinstr2 := TstringList.Create;
postinstr2.Add('encrypt=' + '0');
postinstr2.Add('fid_list=[' + fid_list + ']');
postinstr2.Add('path_list=');
postinstr2.Add('primaryid=' + primaryid);
postinstr2.Add('product=' + 'share');
postinstr2.Add('uk=' + uk);
postinstr2.Add('vcode_input=' + vcode_input);
postinstr2.Add('vcode_str=' + vcode_str);
postResult2 := Fidhttp.Post(apiurl, postinstr2);
realUrl := StringReplace(GetMidString(postResult2, 'dlink":"', '",'), '\',
'', [rfReplaceAll]);
if realUrl <> '' then
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.Memo1.Lines.Add('百度真实地址为(8小时有效):' + realUrl);
MainForm.Edit2.Text := realUrl;
end)
else
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.Memo1.Lines.Add('获取失败,请尝试重新获取');
end)
except
on e: exception do
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.Memo1.Lines.Add(e.Message);
end);
end;
finally
TThread.Synchronize(TThread.CurrentThread,
procedure
begin
MainForm.ActivityIndicator1.Animate := False;
MainForm.Button1.Enabled := True;
postinstr2.DisposeOf;
end);
end;
end;
来源:https://www.amingstudio.com/delphi/368.html
相关阅读 >>
Delphi中怎样得到系统当前“输入法”名称?
Delphi获取我的文档路径
Delphi 判断奇数偶数
Delphi研究之驱动开发篇(七)--利用共享内存与用户模式
Delphi使用api实现模拟按键
Delphi 分割文件合并文件的函数
Delphi中将webbrowser用作网页编辑器
Delphi 使用int3进行hook处理
Delphi 暴力搜索api
Delphi 单击最小化按钮隐藏单击托盘显示
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678