![]() |
|
[.NET] How to get text from webbrowser to vb.net <span> HELP! - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] How to get text from webbrowser to vb.net <span> HELP! (/showthread.php?tid=5725522) |
How to get text from webbrowser to vb.net <span> HELP! - botland - Sep 26, 2017 Hi Forum Thanks in advance who would help me fix this. Tryed lot of things and i still have problem. So let me explain I want to store 3 Values from Webbrowser that are in <span> to vb.net label Here is HTML ( of 3 Values i need ) HTML Code: PHP Code I tryed following with 1 loop because all classes are same. ( NOT WORKING ): Code: Code For Each h As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span")Thank you all, Great forum. * - Brandi Love - Sep 26, 2017 I would personally recommend using htmlagilitypack, it is really easy to parse html using it. Then you can do something like this when you have htmlagilitypack all setup - the documentation is really easy btw. For Each node As HtmlNode In htmldoc.DocumentNode.SelectNodes("//span[@class='_fd86t']") then you can do Dim value As String = node.InnerHtml then you have the values I can give you further guidence on how to set it up if you want? * - botland - Sep 26, 2017 Brandi Love, Thank you, imma try this. One question, htmlagilitypack extract value without webbrowser navigation? I'm kinda new to this. I downloaded libary, what version should i use? Net45 ? Okay i tryed it and nothing happens here is code: Code Imports HtmlAgilityPackEx message: Object reference not set to an instance of an object. Seems that value is null and can't extrack * - Nikola Тesla - Sep 26, 2017 You can use Regular Expressions for this easily. Code For Each m As Match In Regex.Matches(Webbrowser1.DocumentText, "<span class=""(.*?)"">([0-9]{1,10})</span>", RegexOptions.Multiline)and don't forget to import System.Text.RegularExpressions * - botland - Sep 26, 2017 (Sep 26, 2017 04:27 PM)Nikola Тesla Wrote: You can use Regular Expressions for this easily. Tryed not working. * - Nikola Тesla - Sep 26, 2017 (Sep 26, 2017 04:45 PM)botland Wrote: Tryed not working. Code For Each m As Match In Regex.Matches(RichTextBox1.Text, "<span class=""(.*?)"">(.*?)</span>")Try this then? * - botland - Sep 26, 2017 (Sep 26, 2017 04:48 PM)Nikola Тesla Wrote: Na I can't find way. Learning HtmlAgilityPack I just extrack DOC data into textbox and search for that classname and seems that it does not exist. BUT on browser inspect element it does. Anyway i found this in DOC: Quote:<meta content="1,045 Followers, 35 Following, 69 Posts" name="description" /> But one note: Followers, Following, Posts changes everytime so i need select node meta where is name ="description" and get attribute value of content. Teach me how to get content values after it i will parse values. I just need single value. * - DBots - Sep 27, 2017 If it's really bugging you that much, I can help you out through TeamViewer. * - Brandi Love - Sep 27, 2017 I feel like you're gonna have to work through this yourself mand. Just keep on testing. Like an easy way to check if htmlagility pack is working is just look at the html of the entire page and then you can then determine how you are going to scrape the selected parts. * - Xogg - Sep 27, 2017 Just note pretty much all the people in this thread are correct, but you choose which method you use as at the end of the day; it works right? Dont let anyone tell you one is better than another unless there are real facts behind it. * - botland - Sep 27, 2017 (Sep 27, 2017 01:43 PM)Dexuh Wrote: Just note pretty much all the people in this thread are correct, but you choose which method you use as at the end of the day; it works right? Hi, I found best way. (Sep 27, 2017 07:13 AM)Brandi Love Wrote: I feel like you're gonna have to work through this yourself mand. Just keep on testing. Like an easy way to check if htmlagility pack is working is just look at the html of the entire page and then you can then determine how you are going to scrape the selected parts. I got this working, thank you for letting me know about agiltypack this libary is powerfull just need learn select nodes and pretty much everything can be extracked from DOC. (Sep 27, 2017 12:55 AM)DBots Wrote: If it's really bugging you that much, I can help you out through TeamViewer. Nah, i don't need help :) Thank you everyone <3 |