简体   繁体   中英

How can I save the value of an ID from IE to a variable in VBScript?

I would like to write a program that outputs the email from the website "https://10minutemail.net/" in a message box. Unfortunately, I can't find any code that allows me to store the ID in a variable.

I have tried this already without any results:

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)

The code runs with the Error: [unknown error][1]. [1]: https://i.stack.imgur.com/m1yHF.png

How to fix that?

Vbscript use HTML DOM with this method getElementById to get the particular element in a HTML code source page

So in your case, you can give a try with this code:

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM