Hack Forums
[.NET] How to print data off php webpage? - 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 print data off php webpage? (/showthread.php?tid=4924215)



How to print data off php webpage? - Mr Fox - Jul 27, 2015

Let's say i want to go to the page

http://extalia.net/index.php

And get the amount of players online, the number. And print it out into my vb.net form. So something like,

Dim Derp As String = web address
Dim Derp2 As String = Replace("Online", "")

Label1.text = Derp2




Of coarse in the above I need to somehow read the php and search for the line with the specific string "online" and print out the entire string


Any advice?


* - Only3 - Jul 27, 2015

if u just have text in the index then all u need is to use webclient downloadstring with the url which return the text


* - Mr Fox - Jul 27, 2015

(Jul 27, 2015 08:04 AM)Only3 Wrote:  if u just have text in the index then all u need is to use webclient downloadstring with the url which return the text

Can you explain a bit more for me.


* - Only3 - Jul 27, 2015

Label1.text = New Net.WebClient().DownloadString("http://extalia.net/index.php")


* - log dot zip - Jul 27, 2015

[Image: FzuqHzX.png]

EDIT: Don't actually name your MyBase.Load handler "Load", it's bad naming and I only did it because I was too lazy to click the form.


* - Josh‎ - Jul 27, 2015

(Jul 27, 2015 08:41 AM)codeconfusion Wrote:  [Image: FzuqHzX.png]

EDIT: Don't actually name your MyBase.Load handler "Load", it's bad naming and I only did it because I was too lazy to click the form.

I was about to point our your naming of the FormLoad event, then saw the edit at the bottom.


* - Odus - Jul 27, 2015

(Jul 27, 2015 08:41 AM)codeconfusion Wrote:  -snip

What do you think of this pattern instead?

Code
(\d+\,*\d*) ONLINE



* - log dot zip - Jul 27, 2015

(Jul 27, 2015 10:01 AM)Odus Wrote:  What do you think of this pattern instead?

Code
(\d+\,*\d*) ONLINE

I mean, they match the exact same things, just in different ways. :P
edit: Odus's does not use | (or), which in my eyes makes it cleaner (still matches the exact same things however), replace the regex with that instead.


* - +Haze - Jul 27, 2015

(Jul 27, 2015 10:01 AM)Odus Wrote:  What do you think of this pattern instead?

Code
(\d+\,*\d*) ONLINE

@Odus
@CodeConfusion

What if the website had "3,86,600 ONLINE" ? What you then gon do big bois?


* - log dot zip - Jul 27, 2015

(Jul 27, 2015 10:16 AM)+Haze Wrote:  @Odus
@CodeConfusion

What if the website had "3,86,600 ONLINE" ? What you then gon do big bois?

Congratulate them on the unrealistic numbers they've been getting recently.


* - +Haze - Jul 27, 2015

LOOOOOOL, you never know though, one day they could be hitting a milli views. Anway

Code
((\d+\,)+\d+) ONLINE



* - Odus - Jul 27, 2015

(Jul 27, 2015 10:16 AM)+Haze Wrote:  @Odus
@CodeConfusion

What if the website had "3,86,600 ONLINE" ? What you then gon do big bois?

Since we're both nitpicking: not possible as 36,86,600 is not a real number.

Lets be realistic though, the site will likely not breach 999,999 online users at any given time. If it does, then you can account for it with your pattern, but even still... 2 capture groups?


* - +Haze - Jul 27, 2015

Yeah nitpicking ftw. And tru tru tru, I could use a char class.

Code
([\d+\,]+\d+) ONLINE

But yeah I doubt the site would reach 1 mill views lol