The code from the text i want
Thanks :thumb:HTML Code:<pre id="thepaste" class="prettyprint">I WANT THIS TEXT INTO TEXTBOX</pre>
Printable View
The code from the text i want
Thanks :thumb:HTML Code:<pre id="thepaste" class="prettyprint">I WANT THIS TEXT INTO TEXTBOX</pre>
If the site has an API, use that instead. Scraping text from a website is pretty nearly guaranteed to fail eventually, because active sites tend to change their HTML around a whole lot.
If the ID is truly unique for the page, that would be ideal. It really should be, but it doesn't necessarily have to be. If it IS unique, then you can look for the element with that ID. You might give that a try first by looking to see how many matches you get on "thepaste", or 'id="thepaste"'. If you have only one match, that's great.
This is my code
Code:Dim victim As HtmlElement = WebBrowser1.Document.GetElementById("thepaste")
If victim IsNot Nothing Then
Textbox1.Text = victim.InnerText
End If
Does the code work? If not, then where is it located? After all, it is entirely possible that the element hasn't loaded by the time the code is called.
The code doesn't work, if i did i didnt had a problem, but i putted in on the Webbrowser Document Load Complete event so it should be loaded
Yeah, that's a strange variable name. What does it mean?
You would expect that LoadComplete (or is it DocumentComplete) would mean that the document has finished loading. A long time back, you would have been right. Back then, web pages were simple text with some pictures embedded. You asked for a document, you got a document. When you had finished getting the document, it was complete. Those days are long gone. Modern web pages could be as simple as that, but most are not. You will likely get several such events as different parts of a page loads.
This is part of why Shaggy Hiker said to use an API if it was available.
In modern web apps, there's often a lot of magic that the JS wants to do to the page. But it needs the browser to be done with the page before it can do that. So many web apps load a relatively blank page, wait for the "document loaded" event, then use JS to load the *actual* content. That could be your page: it could be true that even after DocumentLoaded not all the content is there.
There's not a "document loaded and JS has finished executing" event. There's no need for it, from a browser's viewpoint. The web wasn't designed for screen scraping. If you can't use an API to get at the data, you're going to have to look at the page's JS and find out what it's doing to load the content you want, then simulate that yourself.