Jump to content

Recommended Posts

Posted (edited)

hello everybody 

I have this html code and wanna get some data using autoit especially 

<h3 itemprop="name" class="entry-title"><a itemprop="url" href="http://www.mywebsite.com/1/" rel="bookmark" title="hello world 1</a></h3>

<h3 itemprop="name" class="entry-title"><a itemprop="url" href="http://www.mywebsite.com/2/" rel="bookmark" title="hello world 2</a></h3>

I need to get the URLs and their titles 

in php I can do this 

$data= file_get_contents($url);
$re= '/<h3 itemprop="name" class="entry-title"><a itemprop="url" href="(.*?)" rel="bookmark" title="(.*?)<\/a><\/h3>/s';
preg_match($re, $data, $match);     
preg_match_all($re,$data,$match);

but I can't do this in autoit 

please help 

Edited by AlienStar
Posted

I think you will need to have a look at the :

StringRegExp

StringRegExpReplace

The IE functions would work too, but it will be different way , and most likely more complicated.

Posted (edited)

I didn't post earlier as you said you wanted Regex. However, if you're willing to use https://www.autoitscript.com/autoit3/docs/libfunctions/_IECreate.htm

Then you can try using something like this (not tested):

Local $h3Tags = _IETagNameGetCollection($ie, "h3")

For $h3Tag In $h3Tags
    Consolewrite(_IEPropertyGet($h3Tag, "InnerText") & @CRLF)
    Consolewrite(_IEPropertyGet($h3Tag, "InnerHTML") & @CRLF)
    Consolewrite($h3Tag.Title & @CRLF)
Next

Edit: Whoops, sorry. I just realised Juvigy isn't the OP.

Edited by IAMK
Posted (edited)
  On 10/2/2018 at 8:19 AM, IAMK said:

I didn't post earlier as you said you wanted Regex. However, if you're willing to use https://www.autoitscript.com/autoit3/docs/libfunctions/_IECreate.htm

Then you can try using something like this (not tested):

Local $h3Tags = _IETagNameGetCollection($ie, "h3")

For $h3Tag In $h3Tags
    Consolewrite(_IEPropertyGet($h3Tag, "InnerText") & @CRLF)
    Consolewrite(_IEPropertyGet($h3Tag, "InnerHTML") & @CRLF)
    Consolewrite($h3Tag.Title & @CRLF)
Next

Edit: Whoops, sorry. I just realised Juvigy isn't the OP.

Expand  

 

thanks so much you gave me the idea to continue :)

Edited by AlienStar
Posted
  On 10/2/2018 at 2:43 AM, AlienStar said:

but I can't do this in autoit 

Expand  

There is a lot of snippets on this forum about this, with examples
BTW If php can do it, then AutoIt can too  -_-

#Include <Array.au3>

$txt = '<h3 itemprop="name" class="entry-title"><a itemprop="url" href="http://www.mywebsite.com/1/" rel="bookmark" title="hello world 1</a></h3>' & @crlf & _ 
    '<h3 itemprop="name" class="entry-title"><a itemprop="url" href="http://www.mywebsite.com/2/" rel="bookmark" title="hello world 2</a></h3>'
; Msgbox(0,"", $txt)

$res = StringRegExp($txt, '(?:href|title)="([^"<]+)', 3)
_ArrayDisplay($res)

 

Posted
  On 10/2/2018 at 6:23 PM, mikell said:

There is a lot of snippets on this forum about this, with examples
BTW If php can do it, then AutoIt can too  -_-

#Include <Array.au3>

$txt = '<h3 itemprop="name" class="entry-title"><a itemprop="url" href="http://www.mywebsite.com/1/" rel="bookmark" title="hello world 1</a></h3>' & @crlf & _ 
    '<h3 itemprop="name" class="entry-title"><a itemprop="url" href="http://www.mywebsite.com/2/" rel="bookmark" title="hello world 2</a></h3>'
; Msgbox(0,"", $txt)

$res = StringRegExp($txt, '(?:href|title)="([^"<]+)', 3)
_ArrayDisplay($res)

 

Expand  

Amazing :lmao::lmao:

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
  • Recently Browsing   0 members

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