libreau3 Posted August 10, 2014 Posted August 10, 2014 Hello All I am attempt ting to retrieve the rates for a particular hotel, but after creating the IE object and clicking the search button I can not retrieve the the html. _IEDocReadHtml() is setting the @error to 0. Does anyone know why this is happening? expandcollapse popup#include <File.au3> #include <IE.au3> #include <Array.au3> #include <Date.au3> #include <String.au3> SplashTextOn("", "Please Wait!", 200, 50) Local $oIE = _IECreate("http://book.bestwestern.com/bestwestern/US/PA/Carbondale-hotels/BEST-WESTERN-Pioneer-Plaza/Hotel-Overview.do?propertyCode=39127") Local $checkAvail = _IEGetObjById($oIE, "searchBtn") _IEAction($checkAvail, "click") _IELoadWait($oIE) Local $sHTML = _IEDocReadHTML($oIE) FileWrite(@DesktopDir & "\Temp.html", $sHTML) _IEQuit($oIE) $html = "" _FileReadToArray(@DesktopDir & "\temp.html", $html) Global $span For $I = 0 To UBound($html) - 1 If StringInStr($html[$I], '<span class="currencyRateDisplay">') Then ConsoleWrite($html[$I]) $temp = _StringBetween($html[$I], '<span class="currencyRateDisplay">', '</span>') $span &= $temp[0] & "|" ConsoleWrite($temp[0]& @CRLF) Else ContinueLoop EndIf Next $span = StringSplit($span, "|", 2) _ArraySort($span) _ArrayDisplay($span) FileDelete(@DesktopDir & "\temp.html") If IsArray($span) = 0 Or UBound($span) < 2 Then IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Min", "Sold Out") IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Max", "Sold Out" & @CRLF) Else IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Min", $span[1]) IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Max", $span[UBound($span) - 1] & @CRLF) EndIf $span = "" ;~ ;Clean Up SplashOff() ShellExecute(@DesktopDir & "\hotel.ini") WinWaitActive("hotel.ini - Notepad", "") WinSetState("hotel.ini - Notepad", "", @SW_MAXIMIZE) WinWaitClose("hotel.ini - Notepad", "") FileDelete(@DesktopDir & "\hotel.ini")
dmob Posted August 11, 2014 Posted August 11, 2014 Your code runs fine on my system, output: [Nicholas Village Clarks Summit] Min=122.55 Max=139.00
libreau3 Posted August 13, 2014 Author Posted August 13, 2014 (edited) My bad I posted the wrong segment of code. expandcollapse popup#include <File.au3> #include <IE.au3> #include <Array.au3> #include <Date.au3> #include <String.au3> SplashTextOn("", "Please Wait!", 200, 50) Local $oIE = _IECreate("https://www.msiwebbooking.com/production/default.aspx?id=eb737f64-5b38-496b-b1eb-00f5d2715e92") $checkAvail = _IEGetObjById($oIE, "ctl00_ContentPlaceHolder1_ImageButton4") _IEAction($checkAvail, "click") Sleep(3000) $load = _IELoadWait($oIE) Local $sHTML = _IEDocReadHTML($oIE) FileWrite(@DesktopDir & "\Temp.html", $sHTML) _IEQuit($oIE) $html = 0 _FileReadToArray(@DesktopDir & "\temp.html", $html) Global $span For $I = 0 To UBound($html) - 1 If StringInStr($html[$I], '<span id="ctl00_ContentPlaceHolder1_ctl05_lblRoomRateValue" class="accordionText">') Then ConsoleWrite($html[$I]) $temp = _StringBetween($html[$I], '<span id="ctl00_ContentPlaceHolder1_ctl05_lblRoomRateValue" class="accordionText">', '</span>') $span &= $temp[0] & "|" ConsoleWrite($temp[0]& @CRLF) Else ContinueLoop EndIf Next $span = StringSplit($span, "|", 2) _ArraySort($span) _ArrayDisplay($span) FileDelete(@DesktopDir & "\temp.html") If IsArray($span) = 0 Or UBound($span) < 2 Then IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Min", "Sold Out") IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Max", "Sold Out" & @CRLF) Else IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Min", $span[1]) IniWrite(@DesktopDir & "\hotel.ini", "Nicholas Village Clarks Summit", "Max", $span[UBound($span) - 1] & @CRLF) EndIf $span = "" ;~ ;Clean Up SplashOff() ShellExecute(@DesktopDir & "\hotel.ini") WinWaitActive("hotel.ini - Notepad", "") WinSetState("hotel.ini - Notepad", "", @SW_MAXIMIZE) WinWaitClose("hotel.ini - Notepad", "") FileDelete(@DesktopDir & "\hotel.ini") Edited August 13, 2014 by libreau3
Solution libreau3 Posted August 13, 2014 Author Solution Posted August 13, 2014 I figured out what my issues was. _IEDocReadHTML was returning something slightly different the what Chrome's Inspect Element was.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now