以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教带登录网页的文件下载 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=157763) |
-- 作者:z769036165 -- 发布时间:2020/10/28 10:19:00 -- 请教带登录网页的文件下载 Dim web As New System.Windows.Forms.WebBrowser() web.ScriptErrorsSuppressed = True web.Navigate("http://pdf.mxjz12.cn/aurora/200-3.html") \'不同登录可直接下载 Do Until web.ReadyState = 4 Application.DoEvents Loop Dim Asc As object = Web.Document.links Dim s As String For Each esa As object In Asc If esa.outerhtml.Contains("Download01") Then s = esa.outerhtml.split("""")(3) Dim hc As New HttpClient(s) If hc.GetFile("D:\\桌面\\新建文件夹\\" & s.split("/")(3)) Then MessageBox.show("文件下载成功","提示") Else MessageBox.show("文件下载失败","提示") End If End If Next web.dispose 如上内容,下载文件没问题,但是如果将web.Navigate("http://pdf.mxjz12.cn/aurora/200-3.html")换成 Dim web As New System.Windows.Forms.WebBrowser() web.ScriptErrorsSuppressed = True web.Navigate("http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=139788") \'需要登录网站用户名密码才能下载 Do Until web.ReadyState = 4 Application.DoEvents Loop Dim Asc As object = Web.Document.links Dim s As String For Each esa As object In Asc If esa.outerhtml.Contains("viewFile.asp") Then s = "http://www.foxtable.com/bbs/" & esa.outerhtml.split("""")(1).Replace("amp;","") Dim hc As New HttpClient(s) If hc.GetFile("D:\\桌面\\新建文件夹\\" & s.split("=")(2) & ".zip") Then MessageBox.show("文件下载成功","提示") Else MessageBox.show("文件下载失败","提示") End If End If Next 结果因为需要登录,结果下载下来的文件全是空文件,打不开,如何通过已知的账号密码,进行登录然后下载对应的文件? [此贴子已经被作者于2020/10/28 10:21:19编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/10/28 10:24:00 -- 参考:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=32808 |
-- 作者:z769036165 -- 发布时间:2020/10/28 11:33:00 -- 还是不行,通过这个自动登录后,下载的还是损坏的压缩包啊 |
-- 作者:z769036165 -- 发布时间:2020/10/28 11:35:00 -- Case "去精华板块" \'web.Navigate("http://www.foxtable.com/bbs/index.asp?boardid=2&TopicMode=0&List_Type=6,0,0&page=") web.Navigate("http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=139788") lb="查找帖子" Case "查找帖子" Dim Asc As object = Web.Document.links Dim s As String For Each esa As object In Asc If esa.outerhtml.Contains("viewFile.asp") Then s = "http://www.foxtable.com/bbs/" & esa.outerhtml.split("""")(1).Replace("amp;","") Dim hc As New HttpClient(s) If hc.GetFile("D:\\桌面\\新建文件夹\\" & s.split("=")(2) & ".zip") Then \'MessageBox.show("文件下载成功","提示") Else \'MessageBox.show("文件下载失败","提示") End If End If Next 修改的内容
|
-- 作者:有点蓝 -- 发布时间:2020/10/28 11:38:00 -- 试试分析一下网页的cookie,添加到HttpClient:http://www.foxtable.com/mobilehelp/topics/0158.htm 如果不行我也没有办法了
|
-- 作者:z769036165 -- 发布时间:2020/10/28 14:09:00 -- 这样可以下载没问题了 |