以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 狐表集成Seafile私有云系统 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=104798) |
||||
-- 作者:天若千颖 -- 发布时间:2017/8/5 11:29:00 -- 狐表集成Seafile私有云系统 多谢版主指导,其实只需要一个默认登录的功能,即可集成Seafile私有云系统。 Seafile私有云系统可自行安装在服务器上:www.seafile.com,开源免费。 只需窗口放置一个Webbrowser控件即可,代码如下: Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol web.ScriptErrorsSuppressed = True web.Navigate("http://123.57.251.28:8000/accounts/login/") \'这里设置你自己的seafile系统网址 Do Until web.ReadyState = 4 Application.DoEvents Loop Dim el = web.Document.GetElementByID("login") If el IsNot Nothing Then el.setattribute("value", "foxtable@163.com") \'这里设置你自己的seafile系统登录账号 End If Dim el2 = web.Document.GetElementByID("password") If el2 IsNot Nothing Then el2.setattribute("value", "123456") \'这里设置你自己的seafile系统登录密码 End If Dim btns = web.Document.GetElementsByTagName("input") For Each btn As object In btns If btn.getattribute("value") = "登录" Then btn.InvokeMember("click") End If Next
[此贴子已经被作者于2017/8/5 15:47:56编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2017/8/5 11:38:00 -- 分析你网页的元素,找到用户和密码输入框名称,改人家2楼的代码 For Each btn As object In btns If btn.getattribute("name") = "login" Then btn.setattribute("value", "foxtable") ElseIf btn.getattribute("name") = "password" Then btn.setattribute("value", "123456") End If Next 同样方法找出按钮名称
|
||||
-- 作者:天若千颖 -- 发布时间:2017/8/5 11:50:00 -- Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol web.ScriptErrorsSuppressed = True web.Navigate("http://123.57.251.28:8000/accounts/login/") Do Until web.ReadyState = 4 Application.DoEvents Loop Dim btns = web.Document.GetElementsByTagName("csrfmiddlewaretoken") For Each btn As object In btns If btn.getattribute("name") = "login" Then btn.setattribute("value", "foxtable@163.com") ElseIf btn.getattribute("name") = "password" Then btn.setattribute("value", "123456") End If Next btns = web.Document.GetElementsByTagName("a") For Each btn As object In btns If btn.getattribute("href") = "javascript:login_onsubmit(0);" Then \'这里不需要该了吗? btn.InvokeMember("click") End If Next 前面没有问题,后面不需要改了吗?这样也登录不了。
|
||||
-- 作者:有点蓝 -- 发布时间:2017/8/5 12:02:00 -- btns = web.Document.GetElementsByTagName("input") For Each btn As object In btns If btn.value = "登录" Then btn.InvokeMember("click") End If Next
|
||||
-- 作者:天若千颖 -- 发布时间:2017/8/5 12:24:00 -- 怎么还是不行呢?
|
||||
-- 作者:有点蓝 -- 发布时间:2017/8/5 14:28:00 -- Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol web.ScriptErrorsSuppressed = True web.Navigate("http://123.57.251.28:8000/accounts/login/") Do Until web.ReadyState = 4 Application.DoEvents Loop Dim el = web.Document.GetElementByID("login") el.setattribute("value", "foxtable@163.com") Dim el2 = web.Document.GetElementByID("password") el2.setattribute("value", "123456") Dim btns = web.Document.GetElementsByTagName("input") For Each btn As object In btns If btn.getattribute("value") = "登录" Then btn.InvokeMember("click") End If Next
|
||||
-- 作者:天若千颖 -- 发布时间:2017/8/5 15:26:00 -- .NET Framework 版本:2.0.50727.8784 Foxtable 版本:2017.6.12.1 错误所在事件:窗口,窗口1,AfterLoad 详细错误信息: 未设置对象变量或 With 块变量。 Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol
web.ScriptErrorsSuppressed = True web.Navigate("http://123.57.251.28:8000/accounts/login/") Do Until web.ReadyState = 4 Application.DoEvents Loop MessageBox.show("1") \'以下开始出错 Dim el = web.Document.GetElementByID("login") el.setattribute("value", "foxtable@163.com") MessageBox.show("2") Dim el2 = web.Document.GetElementByID("password") el2.setattribute("value", "123456") MessageBox.show("3") Dim btns = web.Document.GetElementsByTagName("input") MessageBox.show("4") For Each btn As object In btns If btn.getattribute("value") = "登录" Then btn.InvokeMember("click") End If Next [此贴子已经被作者于2017/8/5 15:31:32编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2017/8/5 15:31:00 -- 判断一下 Dim el = web.Document.GetElementByID("login") if el isnot nothing then el.setattribute("value", "foxtable@163.com") end if
|
||||
-- 作者:天若千颖 -- 发布时间:2017/8/5 15:35:00 -- 多谢版主,两个都判断以下就OK.从而实现FT集成私有云系统。 Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol web.ScriptErrorsSuppressed = True
web.Navigate("http://123.57.251.28:8000/accounts/login/") Do Until web.ReadyState = 4 Application.DoEvents Loop Dim el = web.Document.GetElementByID("login") If el IsNot Nothing Then el.setattribute("value", "foxtable@163.com") End If Dim el2 = web.Document.GetElementByID("password") If el2 IsNot Nothing Then el2.setattribute("value", "123456") End If Dim btns = web.Document.GetElementsByTagName("input") For Each btn As object In btns If btn.getattribute("value") = "登录" Then btn.InvokeMember("click") End If Next [此贴子已经被作者于2017/8/5 15:45:48编辑过]
|
||||
-- 作者:zhy400137 -- 发布时间:2017/8/5 15:55:00 -- mark |