Sign in to follow this  
Followers 0
TehWhale

How to get the number of replies in a topic?

20 posts in this topic

#1 ·  Posted (edited)

I'm tring to see how many posts are in a given topic, so can I do this? I was tring to use the java script:whoposted(15521); stuff, to get who posts or how many, but that didn't work. What IE functions do I need to use, to figure out how many people posted if I have this link, for example:

http://www.autoitscript.com/forum/index.ph...c=81843&hl=

Thanks for all your help!

Edited by SwiftBurns

Share this post


Link to post
Share on other sites



Just so you guys know, this is NOT to make a bot, this is to make a topic watcher, you pick a topic, and it'll notify you when there is a new reply in that topic.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Very helpful. :P

Edited by SwiftBurns

Share this post


Link to post
Share on other sites

hi there

you could analyze the quantity of <a href="http://theforum.com/forum/index.php?showforum=(*.?)"> where (.*?) = something (regexp)

or of <div id=thepost>

cheers!


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

hi there

you could analyze the quantity of <a href="http://theforum.com/forum/index.php?showforum=(*.?)"> where (.*?) = something (regexp)

or of <div id=thepost>

cheers!

Haha, thanks for the reply, but that really means nothing to me. I know how to use StringRegExp and stuff, but no clue how to get that information and stuff.

Share this post


Link to post
Share on other sites

_IEBodyReadHTML()

analyze the page and see how it's better

the <a> method or the <div> one

anyways I think using _InetGetSource() is a better way of doing it rather than using IE object


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

_IEBodyReadHTML()

analyze the page and see how it's better

the <a> method or the <div> one

anyways I think using _InetGetSource() is a better way of doing it rather than using IE object


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Bumpo..

EDIT: I think I got it...

Edited by SwiftBurns

Share this post


Link to post
Share on other sites

I'm getting really unpredictable results with that method.

Heres my code, just put in a random topic link and press the button

#include <Inet.au3>

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 468, 154, 279, 254)
$Edit1 = GUICtrlCreateEdit("", 8, 24, 449, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Label1 = GUICtrlCreateLabel("Topics to watch for new replies", 160, 8, 151, 17)
$Button1 = GUICtrlCreateButton("Engage Topic Watch", 8, 120, 139, 25, 0)
$Button2 = GUICtrlCreateButton("Disengage Topic Watch", 320, 120, 139, 25, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If Not StringInStr(GUICtrlRead($Edit1), @CRLF) Then
                $Source = _INetGetSource(GUICtrlRead($Edit1))
                $Number=1
                Do
                    $Number=$Number+1
                Until Not StringInStr($Source, 'return false;">#'&$Number&'</a>')
                MsgBox(0, "Replies", $Number)
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

A lil help, anyone?

Share this post


Link to post
Share on other sites

Guys, can someone please help me with this. all I need to know is a simple function or udf that can see how many posts are in a topic, using _InetGetSource and StringInStr obviously are not working.

Thanks for all your help!

Share this post


Link to post
Share on other sites

Guys, can someone please help me with this. all I need to know is a simple function or udf that can see how many posts are in a topic, using _InetGetSource and StringInStr obviously are not working.

Thanks for all your help!

Quit bumping your posts so often. Wait at least 24 hours between posts... if you have something else to add to your thread, just edit your last post.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#include <Inet.au3>

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 468, 154, 279, 254)
$Edit1 = GUICtrlCreateEdit("http://www.autoitscript.com/forum/index.php?showtopic=81925", 8, 24, 449, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Label1 = GUICtrlCreateLabel("Topics to watch for new replies", 160, 8, 151, 17)
$Button1 = GUICtrlCreateButton("Engage Topic Watch", 8, 120, 139, 25, 0)
$Button2 = GUICtrlCreateButton("Disengage Topic Watch", 320, 120, 139, 25, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If Not StringInStr(GUICtrlRead($Edit1), @CRLF) Then
                $Source = _INetGetSource(GUICtrlRead($Edit1))
                $Number=1
         While StringInStr($Source, 'return false;">#'&$Number&'</a>')
                    $Number=$Number+1
               WEnd
                MsgBox(0, "Replies", $Number-1)
            EndIf
    EndSwitch
WEnd

The bug about its adding one to the real count is something you must fix by yourself ( meaning that i'm lazy)


My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

A lil help, anyone?

:P

Here:

#include <IE.au3>


$Address = "http://www.autoitscript.com/forum/index.php?showtopic=23860&st=15&start=15"


$FinalPost = "&st=100000"
$Address = StringRegExpReplace($Address, "&st=(.*)", "")
$oIE = _IECreate($Address & $FinalPost, 0, 0)
$text = _IEBodyReadHTML($oIE)
$number  = StringRegExp($text, "#([[:alnum:]]*?)</A", 3)
$number = $number[UBound($number) -  1]




MsgBox(0, "", "Number of posts: " & $number)
Exit

:(

Edited by Szhlopp

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

#include <inet.au3>

Local $a_post_info = _InetGetPostInfo(81925)
If @error Then
    MsgBox(16, "Error", "Error#: " & @error)
Else
    MsgBox(64, "Info", _
        "There are " & $a_post_info[0] & " post(s) per page." & @CRLF & @CRLF & _
        "There are " & $a_post_info[1] & " page(s) total." & @CRLF & @CRLF & _
        "The last url is: http://www.autoitscript.com/forum/index.php?showtopic=" & 81925 & "&st=" & $a_post_info[2] & @CRLF & @CRLF & _
        "The total number of posts for this thread is: " & $a_post_info[3])
EndIf

Func _InetGetPostInfo($i_topic_number)
    Local $s_url = "http://www.autoitscript.com/forum/index.php?showtopic=" & $i_topic_number & "&st="
    Local $s_html = _InetGetSource($s_url)
    Local $a_sre_post_per_page = StringRegExp($s_html, '(?i)return false;">#(\d+)', 3)
    If @error Then Return SetError(1, 0, 0)
    Local $i_pages = 1
    Local $a_sre_pages = StringRegExp($s_html, "(?i)'page-jump'>(\d+)", 3)
    If Not @error Then $i_pages = $a_sre_pages[UBound($a_sre_pages) - 1]
    Local $i_post_per_page = UBound($a_sre_post_per_page)
    Local $i_last_page_post_count = (($i_pages - 1) * $i_post_per_page)
    Local $a_last_post = StringRegExp(_InetGetSource($s_url & $i_last_page_post_count), '(?i)return false;">#(\d+)', 3)
    If @error Then Return SetError(2, 0, 0)
    Local $a_return[4] = [$i_post_per_page, $i_pages, $i_last_page_post_count, UBound($a_last_post)]
    Return $a_return
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#include <inet.au3>

Local $a_post_info = _InetGetPostInfo(81925)
If @error Then
    MsgBox(16, "Error", "Error#: " & @error)
Else
    MsgBox(64, "Info", _
        "There are " & $a_post_info[0] & " post(s) per page." & @CRLF & @CRLF & _
        "There are " & $a_post_info[1] & " page(s) total." & @CRLF & @CRLF & _
        "The last url is: http://www.autoitscript.com/forum/index.php?showtopic=" & 81925 & "&st=" & $a_post_info[2] & @CRLF & @CRLF & _
        "The total number of posts for this thread is: " & $a_post_info[3])
EndIf

Func _InetGetPostInfo($i_topic_number)
    Local $s_url = "http://www.autoitscript.com/forum/index.php?showtopic=" & $i_topic_number & "&st="
    Local $s_html = _InetGetSource($s_url)
    Local $a_sre_post_per_page = StringRegExp($s_html, '(?i)return false;">#(\d+)', 3)
    If @error Then Return SetError(1, 0, 0)
    Local $i_pages = 1
    Local $a_sre_pages = StringRegExp($s_html, "(?i)'page-jump'>(\d+)", 3)
    If Not @error Then $i_pages = $a_sre_pages[UBound($a_sre_pages) - 1]
    Local $i_post_per_page = UBound($a_sre_post_per_page)
    Local $i_last_page_post_count = (($i_pages - 1) * $i_post_per_page)
    Local $a_last_post = StringRegExp(_InetGetSource($s_url & $i_last_page_post_count), '(?i)return false;">#(\d+)', 3)
    If @error Then Return SetError(2, 0, 0)
    Local $a_return[4] = [$i_post_per_page, $i_pages, $i_last_page_post_count, UBound($a_last_post)]
    Return $a_return
EndFunc
With a quick adaption of the SRE for the name/time this would work better SwiftBurns. :P

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Wow thank you so much guys! I must try to test SmOke_N's and Szloops now :P

SmOke_N your's returns 15 per page, 2 pages total, the last URL... and it says the total number of posts for this thread is 2? Theres 17, so is it 15+2?

Edited by SwiftBurns

Share this post


Link to post
Share on other sites

Wow thank you so much guys! I must try to test SmOke_N's and Szloops now :P

I had an error:

#include <Inet.au3>

Local $a_post_info = _InetGetPostInfo(23860)
If @error Then
    MsgBox(16, "Error", "Error#: " & @error)
Else
    MsgBox(64, "Info", _
        "There are " & $a_post_info[0] & " post(s) per page." & @CRLF & @CRLF & _
        "There are " & $a_post_info[1] & " page(s) total." & @CRLF & @CRLF & _
        "The last url is: " & $a_post_info[2] & @CRLF & @CRLF & _
        "The total number of posts for this thread is: " & $a_post_info[3])
EndIf

Func _InetGetPostInfo($i_topic_number)
    Local $s_url = "http://www.autoitscript.com/forum/index.php?showtopic=" & $i_topic_number & "&st="
    Local $s_html = _InetGetSource($s_url)
    Local $a_sre_post_per_page = StringRegExp($s_html, '(?i)return false;">#(\d+)', 3)
    If @error Then Return SetError(1, 0, 0)
    Local $i_pages = 1
    Local $a_sre_pages = StringRegExp($s_html, "(?i)'page-jump'>(\d+)", 1)
    If Not @error Then $i_pages = $a_sre_pages[0]
    Local $i_post_per_page = UBound($a_sre_post_per_page)
    Local $i_last_page_post_count = (($i_pages - 1) * $i_post_per_page)
    Local $a_last_post = StringRegExp(_InetGetSource($s_url & $i_last_page_post_count), '(?i)return false;">#(\d+)', 3)
    If @error Then Return SetError(2, 0, 0)
    Local $a_return[4] = [$i_post_per_page, $i_pages, _
        "http://www.autoitscript.com/forum/index.php?showtopic=" & $i_topic_number & "&st=" & $i_last_page_post_count, _
        $i_last_page_post_count + UBound($a_last_post)]
    Return $a_return
EndFunc
Revised

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

SmOke_N your's returns 15 per page, 2 pages total, the last URL... and it says the total number of posts for this thread is 2? Theres 17, so is it 15+2?

15 I believe is the "default" number of posts ... The results are correct though, it showed 18 posts for this thread which stopped at mine above... That is if you haven't already ran the above.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

15 I believe is the "default" number of posts ... The results are correct though, it showed 18 posts for this thread which stopped at mine above... That is if you haven't already ran the above.

It was fixed in the above one! Thanks :P

Share this post


Link to post
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
Sign in to follow this  
Followers 0