Jump to content

Pulling the newest post in a forum


Recommended Posts

So I wanted to pull the data in a new post on a forum. I think this should be rather easy. This was my attempt

$Url = 'http://s15.zetaboards.com/Sniper_League/topic/7193078'
Global $sSource = BinaryToString(InetRead($Url))
For $i = 1 To 1000 Step +1
$PostCount = StringRegExp($sSource,'(?i)(?s)Post \#(.*?)</a>',1)
MsgBox(0, "Test", $PostCount[0])
If @Error Then
  $Count = $i
  ExitLoop
EndIf
Next
MsgBox(0, "Test", $Count)
Exit
While 1
Sleep(10)
WEnd

So the posts are labeled with numbers, so I was going to do a StringReg, see how many it counts to and then when it errors out I know that it has found the last post. But my thing returns an error because it didn't find a match. The content is:

Post #2</a>

So the stringreg I thought would pull a "1" and then a "2" and stop. But it didn't. Not sure what I did wrong, I've always been fail at StringReg. I'm also quite tired. So I'm heading off to bed, if I don't think of something I'll check back in ;)

Thanks!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Resolved by the following code:

$Url = 'http://s15.zetaboards.com/Sniper_League/topic/7193078'
Global $sSource = BinaryToString(InetRead($Url))
For $i = 1 To 1000 Step +1
$PostCount = StringRegExp($sSource, '(?i)(?s)Post #' & $i & '(.*?)<tr class="c_postfoot">', 1)
$PostData = StringRegExp($PostCount[0], '(?i)(?s)<td class="c_post">(.*?)</td>', 1)
$NewPostData = StringStripWS($PostData[0],3)
MsgBox(0, "Test", $i & $NewPostData)
If @Error Then
  $Count = $i
  ExitLoop
EndIf
Next
MsgBox(0, "Test", $Count)
Exit
While 1
Sleep(10)
WEnd
Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...