Jump to content

InetRead StringRegExp problem?


Recommended Posts

I want to get the expiration date

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)
EndIf

Local $info

Local $expiration_date = StringRegExp($sStr, 'visibility: visible;">','</span></p>', 3)
If UBound($expiration_date) = 3 Then
   $info = "Received data: " & $expiration_date[0] & @CRLF
EndIf

MsgBox(64,"Test",$info)

 

Edited by youtuber
Link to comment
Share on other sites

https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm

StringRegExp.htm  Sample 1 :

$aArray = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '(?i)<test>(.*?)</test>', $STR_REGEXPARRAYMATCH, $iOffset)

I use that on your script this give :

Local $expiration_date = StringRegExp($sStr, '(?i)visibility: visible;">(.*?)</span></p>', 3)

Result : 5 May 2017

Link to comment
Share on other sites

How could this be?

CgF7X3C.png

Local $sStr = InetRead("https://www.autoitscript.com/forum/forum/2-autoit-general-help-and-support/",0)
If @error Then
   MsgBox(16,"Error!","Unable to retrieve information")
Else
   $sStr = BinaryToString($sStr, 0)
EndIf

Local $info

Local $expiration_date = StringRegExp($sStr, '(?i)<span itemprop="name headline">(.*?)</span>', 3)
If UBound($expiration_date) = 3 Then
   $info = "Received data: " & $expiration_date[0] & @CRLF
EndIf

MsgBox(64,"Test",$info)

 

Link to comment
Share on other sites

@Synapsee Thank you for answer

Is this code right?

#include <Array.au3>
#include <String.au3>
Local $sStr = InetRead("https://www.autoitscript.com/forum/forum/2-autoit-general-help-and-support/",0)
If @error Then
   MsgBox(16,"Error!","Unable to retrieve information")
Else
   $sStr = BinaryToString($sStr, 0)
EndIf

 Local $expiration_date = _StringBetween($sStr, '<span itemprop="name headline">','</span>')

_ArrayDisplay($expiration_date)

 

Link to comment
Share on other sites

yeah it's correct, the array is feed...

minor improve : use _StringBetween error

#include <Array.au3>
#include <String.au3>
Local $sStr = InetRead("https://www.autoitscript.com/forum/forum/2-autoit-general-help-and-support/",0)
If @error Then
   MsgBox(16,"Error!","Unable to retrieve information")
Else
   $sStr = BinaryToString($sStr, 0)
EndIf

 Local $expiration_date = _StringBetween($sStr, '<span itemprop="name headline">','</span>')
If @error Then
    MsgBox(16,"Error!","_StringBetween : No strings found")
Else
    _ArrayDisplay($expiration_date)
EndIf

 

Link to comment
Share on other sites

#include <Array.au3>
#include <String.au3>
Local $sStr = InetRead("http://youtubertr.com/StringRegExp.html",0)
If @error Then
   MsgBox(16,"Error!","Unable to retrieve information")
Else
   $sStr = BinaryToString($sStr, 0)
EndIf

Local $expiration_date = StringRegExp($sStr, '(?i)stop-rank">(.*?)</span></font>', 3)
If @error Then
    MsgBox(16,"Error!","StringRegExp error")
Else
    _ArrayDisplay($expiration_date)
    Msgbox(0, "Target", $expiration_date[0])
    ;$expiration_date[0]
    ;Array is $expiration_date
    ;[0] is for array line number
EndIf

Edit :

i warning you about $INET_LOCALCACHE / $INET_FORCERELOAD :

Quote

InetRead ( "URL" [, options = 0] )

options :

$INET_LOCALCACHE (0) = Get the file from local cache if available (default).

$INET_FORCERELOAD (1) = Forces a reload from the remote site.

 

Edited by Synapsee
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...