Jump to content

StringBetween file reading problem


youtuber
 Share

Recommended Posts

I want to get the date 2018-05-05 between results

#include <Array.au3>
#include <Inet.au3>
#include <String.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

;~ <div class="col-md-4 queryResponseBodyKey">Expires On</div>
;~      <div class="col-md-8 queryResponseBodyValue">2018-05-05</div>
SitesExpirationdate()

Func SitesExpirationdate()
Local $sStr = InetRead("http://who.is/whois/autoitscript.com",0)
If @error Then
   MsgBox(16,"Error!","Unable to retrieve information")
Else
   $sStr = BinaryToString($sStr, 0)
$aExtract = _StringBetween($sStr, '<span class="lead">Registrar Info</span>','<div>Information Updated:')
If IsArray($aExtract) Then
Global $aOpenFile = FileOpen(@ScriptDir & '\incomingdataTemp.txt', 1)
 If $aOpenFile = -1 Then
        MsgBox(0, "", "incomingdataTemp.txt The file could not be opened.")
;~ Return False
Else
FileWrite(@ScriptDir & '\incomingdataTemp.txt', $aExtract[0] & @CRLF)
 FileWrite($aOpenFile, $aExtract[0] & @CRLF)
FileClose($aOpenFile)
Local $aArray = FileReadToArray(@ScriptDir & "\incomingdataTemp.txt")
    For $sLine In $aArray
        ;ConsoleWrite($sLine & @CRLF)
        $aExtract2 = _StringBetween($sLine & @CRLF, '<div class="col-md-4 queryResponseBodyKey">Expires On</div>','</div>')

If IsArray($aExtract2) Then
 For $a = 1 To $aExtract2[0]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aExtract2[0] = ' & $aExtract2[0] & @CRLF & '>Error code: ' & @error & @CRLF);
Next
FileClose($aOpenFile)
EndIf
Next
    EndIf
EndIf
EndIf
EndFunc

 

Edited by youtuber
Link to comment
Share on other sites

Hello. You can do something like this:

#include <Array.au3>
Local $sStr = BinaryToString(InetRead("http://who.is/whois/autoitscript.com",1))
Local $aReg = StringRegExp($sStr, "(\d{4}-\d{2}-\d{2})", 1)
_ArrayDisplay($aReg)

Saludos

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...