Jump to content

String Manipulation in Web Page


RNM
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$sString = BinaryToString(InetRead("your URL"))
$sCurrentTime = StringRegExpReplace($sString, "(?i).*current\s.+time:\s?([\d/]+)\s.+", "$1")

George

Question 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!"

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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