Jump to content



Photo

Pulling the newest post in a forum


  • Please log in to reply
1 reply to this topic

#1 Damein

Damein

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 364 posts

Posted 12 May 2012 - 04:08 AM

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!

Posted Image

Most recent sig. I made

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





#2 Damein

Damein

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 364 posts

Posted 12 May 2012 - 10:20 AM

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, 12 May 2012 - 10:24 AM.

Posted Image

Most recent sig. I made

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users