[英]How can I save the value of an ID from IE to a variable in VBScript?
我想編寫一個程序,在消息框中從網站“https://10minutemail.net/”輸出 email。 不幸的是,我找不到任何允許我將 ID 存儲在變量中的代碼。
我已經嘗試過但沒有任何結果:
Dim email
email = ""
set webbrowser = createobject("internetexplorer.application")
webbrowser.statusbar = false
webbrowser.menubar = false
webbrowser.toolbar = false
webbrowser.visible = false
webbrowser.navigate("10minutemail.net")
email = webbrowser.document.all.item("fe_text")
wscript.echo(email)
代碼運行時出現錯誤:[未知錯誤][1]。 [1]: https://i.stack.imgur.com/m1yHF.png
如何解決?
Vbscript 使用 HTML DOM 和此方法getElementById
獲取 HTML 代碼源頁面中的特定元素
因此,在您的情況下,您可以嘗試使用以下代碼:
Option Explicit
Dim IE,Email_Value
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.navigate "https://10minutemail.net/"
Do While (IE.Busy)
WScript.Sleep 100
Loop
Email_Value = IE.document.getElementByID("fe_text").Value
wscript.echo(Email_Value)
IE.Quit()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.