RNM 0 Posted October 20, 2010 Hi All, I have a web page that I need to pull a date from. The string in the web page shows: (Current server time:10/20/2010 07:59:13) I need the date... how do I find and retrieve that value? Thanks! Share this post Link to post Share on other sites
water 2,387 Posted October 20, 2010 Something like this: $sString = BinaryToString(InetRead("your URL")) ;$sString = "The page shows:(Current server time:10/20/2010 07:59:13)I need the date..." ; Testdata $iPos = StringInStr($sString, "(Current server time:") $sDateTime = StringMid($sString, $iPos + 21, 19) MsgBox(0, "", $sDateTime) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
saywell 3 Posted October 20, 2010 If the format is completely consistent, StringTrimRight and ...Left would do it, too. William Share this post Link to post Share on other sites
GEOSoft 67 Posted October 20, 2010 $sString = BinaryToString(InetRead("your URL")) $sCurrentTime = StringRegExpReplace($sString, "(?i).*current\s.+time:\s?([\d/]+)\s.+", "$1") GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!" Share this post Link to post Share on other sites
RNM 0 Posted October 20, 2010 $sString = BinaryToString(InetRead("your URL")) $sCurrentTime = StringRegExpReplace($sString, "(?i).*current\s.+time:\s?([\d/]+)\s.+", "$1") Perfect... thanks everyone! Share this post Link to post Share on other sites
PsaltyDS 39 Posted October 20, 2010 If you want to work with the DOM, it might look something like this: #include <IE.au3> $sTimeURL = "http://www.time.gov/timezone.cgi?UTC/s/0" $oIE = _IECreate($sTimeURL) $colTD = _IETagNameGetCollection($oIE, "td") For $oTD In $colTD If StringRegExp($oTD.innerText, "\d{2}\:\d{2}\:\d{2}", 0) Then $aTime = StringRegExp($oTD.innerText, "(?s)(?U)(\d{2}\:\d{2}\:\d{2}).+([[:alpha:]]+\,\s[[:alpha:]]+\s\d{2},\s\d{4})", 1) If IsArray($aTime) and UBound($aTime) >= 2 Then ConsoleWrite("Time = " & $aTime[0] & @CRLF & "Date = " & $aTime[1] & @LF) EndIf ExitLoop EndIf Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites