Question[Help]# Posts in a forum[solved]

Posts 115 of 46 · Page 1 of 4
[Help]# Posts in a forum[solved]
Basically, I want to find the number of posts on mpgh and display it as a label.text.

For example my user profile is here:
http://www.mpgh.net/forum/members/378727-ppl2pass.html

And right now i have 209 posts.

Basically, the program will read the source of that page and find this line:
Code:
Total Posts:</span> 209</li>
But this will be different for everyone.
How would i display the number of post in a label for different users.
What website is it, if it has a ID super Easy, if not, I will work something out.
NextGen1 Edit:
Namespace
[php]
Imports System.Net
Imports System.IO
Imports System.Text.RegularExpressions
[/php]

Code:
 Dim Request As HttpWebRequest = HttpWebRequest.Create("http://www.mpgh.net/forum/members/378727-ppl2pass.html")
        Dim Response As HttpWebResponse = Request.GetResponse()
        Dim reader As StreamReader = New StreamReader(Response.GetResponseStream)
        Dim httpContent As String
        httpContent = reader.ReadToEnd

        Dim ViewRegEx As New Regex("Total Posts:</span>(?<Views>(.*))</li>")
        Dim Views As String
        Views = (Mid$(ViewRegEx.Match(httpContent).Groups("Views").ToString, 1, 46))


       label1.text = Views.Replace("</li> <li><span class=""shade"">Posts Per Da", "")
This should get you the posts of a certain member...
added the namespace, and yes it is A-typical Context reader with Http and XML
Still would like the site, the reason I asked is content will be different, and I don't think it is for mpgh.

@blubb, Good Job

@ppl ,
Ok it is for mpgh , You will need their address link. in this example, short of database access , you won't have that information (unless you use PHP and post , but that's asp.net)

Best bet is to allow the user during setup to add their url



i have a good idea.

to make this happen, i will use a webbrowser in vb.net
i will then tell people to login on the webbrowser.
after they login i will take the source of the webpage and find this line:
Code:
<strong>Welcome, <a href="http://www.mpgh.net/forum/members/378727-ppl2pass.html">ppl2pass</a>
will this work?
Exactly PPL, that should work fine

at blubb
at NextGen1 or Blubb

would you explain this code as i will try this for the welcome one.

Code:
        Dim ViewRegEx As New Regex("Total Posts:</span>(?<Views>(.*))</li>")
        Dim Views As String
        Views = (Mid$(ViewRegEx.Match(httpContent).Groups("Views").ToString, 1, 46))


       label1.text = Views.Replace("</li> <li><span class=""shade"">Posts Per Da", "")
espcially this:
Code:
(?<Views>(.*))
how do you know this?
You can change "(?<Views>(.*))" to whatever you want.

The "(.*)" tells the program, that the string of "Views" can have any length, since we don't what the length is. It can be 4 numbers but also 8. You don't know.

The "?" tells the program, that it should extract the variable between the <> in this case "Views".

In this line of code Regex is started("Views = (Mid$(ViewRegEx.Match(httpContent).Groups("Views") .ToString, 1, 46))")

httpcontent = the text to be searched in...

Views = The variable the amount of views is saved in...

Mid$ extracts a lot of crap. Without mid$ you'd get a lot of other code as result. It basically extract all characters whose are not in the area from 1-46.


Sorry for this crappy English. I have no idea how to say it =P

In computing, regular expressions, also referred to as regex or regexp, provide a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.
ok ty. i got one more question.
how would you view the page source of a webbrowser?
Code:
dim source as string = webbrowser1.documenttext
to make sure the webbrowser is loaded use the following code:

Code:
While not webbrowser1.readystate = readystate.completed 
application.doevents
end with
readystate.completed is prolly written somehow else, you'll see....
this functoin doesnt work.

While not webbrowser1.readystate = readystate.completed
application.doevents
end with

readstate.completed not defined.

also how do you get the url of webbrower1.
Quote Originally Posted by ppl2pass View Post
this functoin doesnt work.

While not webbrowser1.readystate = readystate.completed
application.doevents
end with

readstate.completed not defined.

also how do you get the url of webbrower1.
[php]
Dim source As String = WebBrowser1.DocumentText

While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
End While
[/php]
how would you be able to find and read this url for each user:

Code:
http://www.mpgh.net/forum/members/378727-ppl2pass.html">ppl2pass
Code:
<strong>Welcome, <a href="http://www.mpgh.net/forum/members/378727-ppl2pass.html">ppl2pass</a>.</strong>
Posts 115 of 46 · Page 1 of 4
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?