使用 Selenium 加载 html body insideHTML
我正在寻找一种将 HTML 正文加载到 selenium bot 中的方法,
html.body.innerHTML = .responseText
'
Set bot = New Selenium.ChromeDriver
bot.Get HERE
是否可以执行这样的任务,或者我必须将 html 正文保存到文件中然后导航到该文件?
我可以通过使用此过程将 html 正文导出到文件来管理此操作
Sub ExportHTML(sInput As String)
With CreateObject("ADODB.Stream")
.Charset = "UTF-8"
.Open
.WriteText sInput
.SaveToFile Environ("USERPROFILE") & "\Desktop\OutputHTML.html", 2
.Close
End With
End Sub
之后,我可以使用 selenium 驱动程序加载文件,如下所示
bot.Get "file:///" & Environ("USERPROFILE") & "\Desktop\OutputHTML.html"
I am searching for a way to load the HTML body into selenium bot
html.body.innerHTML = .responseText
'
Set bot = New Selenium.ChromeDriver
bot.Get HERE
Is it possible to do such a task or I have to save the html body to a file then navigate to that file?
I could manage that by exporting the html body to a file using this procedure
Sub ExportHTML(sInput As String)
With CreateObject("ADODB.Stream")
.Charset = "UTF-8"
.Open
.WriteText sInput
.SaveToFile Environ("USERPROFILE") & "\Desktop\OutputHTML.html", 2
.Close
End With
End Sub
After that I could load the file using the selenium driver like that
bot.Get "file:///" & Environ("USERPROFILE") & "\Desktop\OutputHTML.html"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法单独加载 HTML 正文,因为其核心表单中的 HTML 文档由两个强制部分组成:
< ;body>
简单 HTML 文档示例:
You can't load the HTML body seperately as the HTML Document in it's core form consists of two manadatory parts:
<head>
<body>
Example of a simple HTML document: