![]() |
|
[.NET] [Easy] Get any value from any website [Regex] - 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] [Easy] Get any value from any website [Regex] (/showthread.php?tid=2980765) Pages: Pages
1
2
|
[Easy] Get any value from any website [Regex] - Shoсkwave - Oct 29, 2012 Hey guys this tutorial I will be showing you how to get nearly any value from a website using a regex function.
The function: Code Public Shared Function RegexMatch(ByVal Text As String, ByVal Regexstring As String) As MatchCollectionUsage: Code For Each m As Match In RegexMatch(SourceCode, RegexString)Say we want to get a fresh proxy list from http://www.xroxy.com/proxylist.php We want to get the highlighted value here: Spoiler (Click to View) It is really simple using this function, so we get the page source either from grabbing it with a webrequest/webclient or just copying the source into a richtextbox, either way. So here is how it is done, we see before the proxy and port there is this: Code proxy:name=XROXY proxy&host=121.52.210.22&port=28889the ".*" means anything can be there so we grab all strings like that. Now if we set the value's that we have just grabbed into a richtextbox it should look like this: Spoiler (Click to View) We have grabbed the ips but it is a mess, we have to format it using the Split() function, it is quite self explanatory, this is what our function should look like now: And we have now successfully extracted the strings in ip/port format. If you have any questions or problems let me know, thanks guys. * - marvinn - Oct 29, 2012 You.should use groups so you do not need to split all the data again. * - Weakky. - Oct 29, 2012 (Oct 29, 2012 05:46 AM)marvinn Wrote: You.should use groups so you do not need to split all the data again. This. Just use (.*) to create a groups then just use Code MsgBox(m.Groups(1).Value)* - Shoсkwave - Oct 29, 2012 (Oct 29, 2012 05:51 AM)TRANSLU6DE Wrote: This. Just use (.*) to create a groups then just use I didn't know about that man, thanks alot. * - marvinn - Oct 29, 2012 You can even use this Code var reg = new Regex(proxy&host=(.*)&port=(.*))An other tip, check http://regexpal.com That helps a lot ;) * - Giommi - Oct 29, 2012 Thanks ! I really need this for my Projects in Future Ty so much! * - evol - Oct 29, 2012 Arrh Regex the one thing that turns my brain to mush thanks for the easy to follow tutorial. 🙂 * - Gr0wlit - Oct 29, 2012 Pretty cool, thanks for this sharing. Now i'm using the nice 'GetBetween' function, but i've tried this one, and i think to switch to this one! Thanks! * - aTastyUnicorn - Nov 20, 2012 Can you upload again the pictures, please. * - Pussy Cat - Nov 20, 2012 If you're just getting value between something such as this, Split would be faster compared to Regex. Regex isn't just about .*, if you're just gonna use .* everywhere then you don't really need to use regex. * - 0dayleet - Nov 24, 2012 Pretty awesome tutorial, thank you for posting it! :D * - Cairns - Jan 18, 2013 This is kinda useless using both split and regex, it's best to use one or the other. Regex is a good bit faster if you know how to write proper patterns. In this case you should have just used split * - Pussy Cat - Jan 18, 2013 (Jan 18, 2013 05:58 AM)Cairns Wrote: This is kinda useless using both split and regex, it's best to use one or the other. Regex is a good bit faster if you know how to write proper patterns. In this case you should have just used split This. Regular split is usually faster performance-wise compared to Regex in most cases, sometimes the split just isn't enough though and we have to use Regex. * - Cairns - Jan 18, 2013 I have coded a bot in the past that has harvested up to 1000s of links per page. I tried splitting them each time and it was okay the speed. I used regex to test its speed and found that regex ran much better. But I suppose it can change in most cases * - Pussy Cat - Jan 18, 2013 (Jan 18, 2013 06:40 AM)Cairns Wrote: I have coded a bot in the past that has harvested up to 1000s of links per page. I tried splitting them each time and it was okay the speed. I used regex to test its speed and found that regex ran much better. But I suppose it can change in most cases That's because you had to call the Split method multiple times, with Regex you just have to call the Matches method once. |