[Help] GetElementById , Simple question

Posts 1–15 of 17 · Page 1 of 2
[Help] GetElementById , Simple question
Code:
If MyForm.Contains(WebBrowser) = False And I.Can.GetElementById = True Then
Msgbox(How?)
End if
Can you elaborate I'm not sure I get your question, I think if you want to get the ElementByID use
Code:
Webbrowser1.Document.GetElementbyID ("?")
Lol NO, I want to getElementById without Webbrowser xD
If possible..
THen
Code:
Imports System.net
Dim e as String = New Webclient().Downloadstring("?")
Then just use the Get Element by ID
Quote Originally Posted by VernK View Post
THen
Code:
Imports System.net
Dim e as String = New Webclient().Downloadstring("?")
Then just use the Get Element by ID
YAh , How -_-
Not that easy, You cant do e.GetElementById("BLABLA")
Didn't Jason help you to make your IP manager without WB? Try PMing him he probably knows

@Jason @Hassan
Quote Originally Posted by VernK View Post
Didn't Jason help you to make your IP manager without WB? Try PMing him he probably knows

@Jason @Hassan
lol That was with XML...
if (browser.Document.GetElementbyID("freedompeace") != null)
// element exists..
Quote Originally Posted by freedompeace View Post
if (browser.Document.GetElementbyID("freedompeace") != null)
// element exists..
He's trying to use the Function GetElementByID without using a webbrowser. Basically like calling Form1.Show() without Form1...

1) If this is for your IP manager, you can try downloading the webpage's source using a WebClient and then loading the HTML/XML into an XMLDocument or whatever its called.
2) mshtml.
Quote Originally Posted by Iamazn1 View Post
He's trying to use the Function GetElementByID without using a webbrowser. Basically like calling Form1.Show() without Form1...

1) If this is for your IP manager, you can try downloading the webpage's source using a WebClient and then loading the HTML/XML into an XMLDocument or whatever its called.
2) mshtmlⓘ.
I DIDN SAY NOTHING ABOUT IP MANAGER.

Im just asking if is possible getElementbyId without a webbrowser.
Use the library Jason released few days ago. And learn string manipulation.
You can do it, but it means using a COM object called HTML Object Library. It renders text into a HTML document which you can then call getElementById...etc. IMO you should just create a custom function to find it, or as Hassan said, use my library.

Here's some code that I'd start with, using RegEx

[highlight=vb.net]
Imports System.Text.RegularExpressions
[/highlight]

[highlight=vb.net]
Private Function ReplaceMetachars(ByVal input As String) As String
Dim output As String = input
Dim chars As String = "[\+*?(|$^.)"
For Each s As String In chars
output = output.Replace(s, "\" & s)
Next
Return output
End Function

Private Function GetElementByID(ByVal ID As String, ByVal src As String) As String
Dim idPattern As String = "<([a-zA-Z]*)\s.*?id=""" & ReplaceMetachars(ID) & """[\s\S]*?</\1>"
Dim m As Match = Regex.Match(src, idPattern, RegexOptions.Compiled)
Return m.Value
End Function
[/highlight]

And after that I'd probably build a custom "Element" class to do various operations on the value so that it's similar to a HTMLElement in terms of functionality. Then I'd make the function return an "Element" instead of a raw string.
Jason, what if the tag contains numbers ?

Modified a bit to support numbers in tag:

[highlight=vbnet]Dim idPattern As String = "<([a-zA-Z0-9]*)\s.*?id=""" & ReplaceMetachars(ID) & """[\s\S]*?</\1>"[/highlight]
Quote Originally Posted by Hassan View Post
Jason, what if the tag contains numbers ?

Modified a bit to support numbers in tag:

[highlight=vbnet]Dim idPattern As String = "<([a-zA-Z0-9]*)\s.*?id=""" & ReplaceMetachars(ID) & """[\s\S]*?</\1>"[/highlight]
DERP, i forgot that the "h" tags have numbers. My bad. Seeing as you're using the whole character class, may as well just do

[highlight=vbnet]Dim idPattern As String = "<(\w*)\s.*?id=""" & ReplaceMetachars(ID) & """[\s\S]*?</\1>"[/highlight]
Quote Originally Posted by Iamazn1 View Post
He's trying to use the Function GetElementByID without using a webbrowser. Basically like calling Form1.Show() without Form1...

1) If this is for your IP manager, you can try downloading the webpage's source using a WebClient and then loading the HTML/XML into an XMLDocument or whatever its called.
2) mshtml.
"I.Can.GetElementById = True"

Then what on earth does that mean? :/
Posts 1–15 of 17 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us