Jump to content

Recommended Posts

Posted (edited)

Need help counting the "Green" available camping sites on the website then move to the next page and do the same while adding them to the count and so on for each page.  I found the _IE_Example("basic") from the help file ant it seems to do what I generally want but it is just not picking up the "Green" buttons and counting them.

-----------------------------------------------------------------------------

#include <AutoItConstants.au3>
#include <IE.au3>
#include <Array.au3>

Local $oIEBasic = _IECreate("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=03%2F02%2F2021&nights=4&category=Smith+Point&subtype=&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=&gotopagenow=&gotopage=1&module=RN&multiselectlist_value=")
Local $sMyString = "Add To Selection List"

Local $oAllWebsiteLinks = _IELinkGetCollection($oIEBAsic)
Local $aLinkPaths[@extended]
Local $i = 0

For $oSingleLink In $oAllWebsiteLinks
     $aLinkPaths[$i] = _IEPropertyGet($oSingleLink, "innertext")
     $i = $i + 1
Next

_IEQuit ($oIEBasic)

_ArrayDisplay($aLinkPaths)

Edited by JayT
Posted

An alternative to using the _IE commands is to use InetRead, which should be much quicker. For example, this reads the 2nd page and displays the available count --

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sCompare = 'data-icon-primary="ui-icon-plusthick"'

    ; Read the file without downloading to a folder. The option of 'get the file from the local cache' has been selected.
    Local $dData = InetRead("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=03%2F02%2F2021&nights=4&category=Smith+Point&subtype=&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=2&gotopagenow=&gotopage=1&module=RN&multiselectlist_value=", $INET_FORCERELOAD)

    ; The number of bytes read is returned using the @extended macro.
    Local $iBytesRead = @extended

    ; Convert the ANSI compatible binary string back into a string.
    Local $sData = BinaryToString($dData)

    ; Count the number of available sites
    $sData = StringReplace($sData, $sCompare, $sCompare)

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", "The number of occurences: " & @extended)
EndFunc   ;==>Example

You would need to dynamically build the URL for each page, retrieve the HTML, then count the available sites.

Posted (edited)

This is great! Thank you!! I have one more question, How would I add this function to my gui? I need it to read the specific options that the user selects from the GUI.

$Form1_1 = GUICreate("Camping Reservation Checker", 626, 407, 192, 124)
$Heading = GUICtrlCreateLabel("Select a Park ", 200, 40, 79, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Combo1 = GUICtrlCreateCombo("Smith Point", 304, 40, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData ($Combo1,"Cupsogue|Indian+Island|Montauk|Sears+bellows|Shinnecock+East|Southhaven|West+Hills")
$Submit = GUICtrlCreateButton("Submit", 296, 312, 75, 25)
$Label1 = GUICtrlCreateLabel("Check Availability", 272, 192, 149, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("..\Autoit Scripts\images\Camper.jpg", 8, 8, 132, 116)
$Date = GUICtrlCreateLabel("Enter Date:", 200, 240, 70, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Month = GUICtrlCreateCombo("Month", 272, 240, 57, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Month,"01|02|03|04|05|06|07|08|09|10|11|12|")
$Day = GUICtrlCreateCombo("Day", 336, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Day, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30")
$Year = GUICtrlCreateCombo("2021", 408, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Year,"2021|2022")
$hookups = GUICtrlCreateCombo("Sewer", 304, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData ($hookups,"Basic|Electric|Outer+Beach")
$Label3 = GUICtrlCreateLabel("Select Hookup", 200, 72, 84, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Number_of_Nights = GUICtrlCreateCombo("4", 304, 104, 145, 21)
GUICtrlSetData ($Number_of_Nights,"5|6|7|8|9|10|11|12|13|14")
$Label2 = GUICtrlCreateLabel("Number of Nights", 192, 104, 101, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Group1 = GUICtrlCreateGroup("", 160, 8, 345, 153)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 160, 184, 345, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Submit
            sleep (1000)
            $Date2 = GUICtrlRead ($Day)
            $Date1 = GUICtrlRead ($Month)
            $Date3 = GUICtrlRead ($Year)
            $location = GUICtrlRead ($Combo1)
            $hookup = GUICtrlRead ($hookups)
            $nights = GUICtrlRead ($Number_of_Nights)
            GUICtrlSetData($Day, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30")
            GUICtrlSetData($Month,"01|02|03|04|05|06|07|08|09|10|11|12|")

Opt("WinTitleMatchMode", 2)
$oIE = _IECreate ("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=" & $date1 & "%2F" & $Date2 & "%2F" & $Date3 & "&nights=" & $nights & "&category=" & $location & "&subtype=" & $hookup & "&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=&gotopagenow=&gotopage=1&module=RN&multiselectlist_value=&rnwebsearch_buttonsearch=Search")
WinSetState ( "Internet", "", @SW_MAXIMIZE )
$oIE.document.parentwindow.scroll(0,1000)

    EndSwitch
WEnd

 

Edited by JayT
Posted

Okay, thanks for showing me.  I Hope it's correct now. I will try your suggestion regarding using GUIctrlRead to build the URL string. I am a little confused but I will try and use the help page.

Posted

okay, I tried the following code however it does not seem to be executing the "Function" section. I guess this is why I am not a coder 😕

$Form1_1 = GUICreate("Camping Reservation Checker", 626, 407, 192, 124)
$Heading = GUICtrlCreateLabel("Select a Park ", 200, 40, 79, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Combo1 = GUICtrlCreateCombo("Smith Point", 304, 40, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData ($Combo1,"Cupsogue|Indian+Island|Montauk|Sears+bellows|Shinnecock+East|Southhaven|West+Hills")
$Submit = GUICtrlCreateButton("Submit", 296, 312, 75, 25)
$Label1 = GUICtrlCreateLabel("Check Availability", 272, 192, 149, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("..\Autoit Scripts\images\Camper.jpg", 8, 8, 132, 116)
$Date = GUICtrlCreateLabel("Enter Date:", 200, 240, 70, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Month = GUICtrlCreateCombo("Month", 272, 240, 57, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Month,"01|02|03|04|05|06|07|08|09|10|11|12|")
$Day = GUICtrlCreateCombo("Day", 336, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Day, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30")
$Year = GUICtrlCreateCombo("2021", 408, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Year,"2021|2022")
$hookups = GUICtrlCreateCombo("Sewer", 304, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData ($hookups,"Basic|Electric|Outer+Beach")
$Label3 = GUICtrlCreateLabel("Select Hookup", 200, 72, 84, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Number_of_Nights = GUICtrlCreateCombo("4", 304, 104, 145, 21)
GUICtrlSetData ($Number_of_Nights,"5|6|7|8|9|10|11|12|13|14")
$Label2 = GUICtrlCreateLabel("Number of Nights", 192, 104, 101, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Group1 = GUICtrlCreateGroup("", 160, 8, 345, 153)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 160, 184, 345, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Submit
            sleep (1000)
            $Date2 = GUICtrlRead ($Day)
            $Date1 = GUICtrlRead ($Month)
            $Date3 = GUICtrlRead ($Year)
            $location = GUICtrlRead ($Combo1)
            $hookup = GUICtrlRead ($hookups)
            $nights = GUICtrlRead ($Number_of_Nights)
            GUICtrlSetData($Day, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30")
            GUICtrlSetData($Month,"01|02|03|04|05|06|07|08|09|10|11|12|")

;Opt("WinTitleMatchMode", 2)
;$oIE = _IECreate ("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=" & $date1 & "%2F" & $Date2 & "%2F" & $Date3 & "&nights=" & $nights & "&category=" & $location & "&subtype=" & $hookup & "&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=&gotopagenow=&gotopage=1&module=RN&multiselectlist_value=&rnwebsearch_buttonsearch=Search")
;WinSetState ( "Internet", "", @SW_MAXIMIZE )
;$oIE.document.parentwindow.scroll(0,1000)

    EndSwitch
WEnd

Example()

Func Example()
    Local $sCompare = 'data-icon-primary="ui-icon-plusthick"'

    ; Read the file without downloading to a folder. The option of 'get the file from the local cache' has been selected.
     ;Local $dData = InetRead ($oIE)
    Local $dData = InetRead("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=" & $date1 & "%2F" & $Date2 & "%2F" & $Date3 & "&nights=" & $nights & "&category=" & $location & "&subtype=" & $hookup & "&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=&gotopagenow=&gotopage=1&module=RN&multiselectlist_value=&rnwebsearch_buttonsearch=Search")

    ; The number of bytes read is returned using the @extended macro.
    Local $iBytesRead = @extended

    ; Convert the ANSI compatible binary string back into a string.
    Local $sData = BinaryToString($dData)

    ; Count the number of available sites
    $sData = StringReplace($sData, $sCompare, $sCompare)

    ; Display the results.
    MsgBox("", "Sites Available", "There Are " & @extended & " Sites Available!")
EndFunc   ;==>Example

;Func exitScript()
   ; Exit
;EndFunc

 

Posted (edited)

Is there a way to capture the number of available sites on one page then go to the next page and add them? This is hindering the point of this project. It was supposed to be a way we can check if there were sites available without having to go on the website and search. If there are no sites available on the first page the program report no sites available which may not be true. Maybe something like adding it to an array. I heard something about these "Array" things but don't know anything about them other than they display your data.

Edited by JayT
Posted (edited)

You can create Listview with each row for each location and where one column will be "Status" OK/ERR or Online/Offline.

At the start of your application you will loop for all locations and finally create Listview item for each location with resulting status.

 

Lok at GUICtrlCreateListView(), GUICtrlCreateListViewItem()

Edited by Zedna
Posted

I am not sure this is what I was looking for. I would like more of a simple number of all available sites in a message box. Not saying your way is not correct I am just ignorant when it comes to this stuff. Learning as I go. I appreciate your suggestion though. 

Posted
Posted

Danp2 your example was great and helped me greatly!!! I am just stuck on how to "store" this count and move to the next page and do it again. I am trying to learn believe me I am. I hate to bother you guys with my ignorance.

Posted

Here how you could do it :

#include <InetConstants.au3>
#include <Constants.au3>
#include <Array.au3>

Example()

Func Example()
  Local $sCompare = 'data-icon-primary="ui-icon-plusthick"'

  ; Get page 1
  Local $dData = InetRead("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=03%2F16%2F2021&nights=4&category=Cedar+Point&subtype=&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=1&gotopagenow=yes&gotopage=1&module=RN&multiselectlist_value=", $INET_FORCERELOAD)
  Local $sData = BinaryToString($dData)

  ;ConsoleWrite ($sData & @CRLF)
  Local $aPage = StringRegExp($sData, '<option value="(\d+)', 3)
  _ArrayDisplay($aPage)
  Local $nPage = $aPage[UBound($aPage)-1]

  StringReplace($sData, $sCompare, $sCompare)
  Local $iTotal = @extended

  ; loop thru all pages using $i as page indicator
  For $i = 2 to $nPage
    $dData = InetRead("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=03%2F16%2F2021&nights=4&category=Cedar+Point&subtype=&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=" & $i & "&gotopagenow=yes&gotopage=1&module=RN&multiselectlist_value=", $INET_FORCERELOAD)
    $sData = BinaryToString($dData)
    StringReplace($sData, $sCompare, $sCompare)
    $iTotal += @extended
  Next
  MsgBox($MB_SYSTEMMODAL, "", "Total number is " & $iTotal)
EndFunc   ;==>Example

 

Posted

Nine, Your help was great and somewhat worked. Unfortunately it is returning inaccurate count? I do appreciate your assistance with this. Thank you!

Posted
Posted

So I modified it to work with my Gui as I posted earlier. Here is the current code. It seems to be 4-5 number higher then what is available.

Func Example()
  Local $sCompare = 'data-icon-primary="ui-icon-plusthick"'

  ; Get page 1
    Local $dData = InetRead("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=" & $date1 & "%2F" & $Date2 & "%2F" & $Date3 & "&nights=" & $nights & "&category=" & $location & "&subtype=" & $hookup & "&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=&gotopagenow=&gotopage=1&module=RN&multiselectlist_value=", $INET_FORCERELOAD)

  Local $sData = BinaryToString($dData)

  ;ConsoleWrite ($sData & @CRLF)
  Local $aPage = StringRegExp($sData, '<option value="(\d+)', 3)
  ;_ArrayDisplay($aPage)
  Local $nPage = $aPage[UBound($aPage)-1]

  StringReplace($sData, $sCompare, $sCompare)
  Local $iTotal = @extended

  ; loop thru all pages using $i as page indicator
  For $i = 2 to $nPage
    $dData = InetRead("https://parks.suffolkcountyny.gov/wbwsc/webtrac.wsc/search.html?Action=Start&SubAction=&rnwebsearch_search=Yes&primarycode=&begindate=" & $date1 & "%2F" & $Date2 & "%2F" & $Date3 & "&nights=" & $nights & "&category=" & $location & "&subtype=" & $hookup & "&type=FamilySite&begintime=12%3A00+am&endtime=12%3A00+am&quantity=1&keyword=&display=Listing&search=yes&page=" & $i & "&gotopagenow=yes&gotopage=1&module=RN&multiselectlist_value=", $INET_FORCERELOAD)

    $sData = BinaryToString($dData)
    StringReplace($sData, $sCompare, $sCompare)
    $iTotal += @extended
  Next
  MsgBox($MB_SYSTEMMODAL, "", "There Are " & $iTotal & " Sites Available at " & $location)

;ElseIf $aBox = 7 Then
   ; Exit

;EndIf
EndFunc   ;==>Example

 

Posted (edited)

I think I figured it out. In the URL gotopage= need to be 0. It is counting correct now.

gotopage=1

 

Edited by JayT

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
  • Recently Browsing   0 members

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