AlienStar Posted October 2, 2018 Share Posted October 2, 2018 (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 October 2, 2018 by AlienStar Link to comment Share on other sites More sharing options...
Subz Posted October 2, 2018 Share Posted October 2, 2018 Have you looked at the IE functions in the help file? AlienStar 1 Link to comment Share on other sites More sharing options...
Juvigy Posted October 2, 2018 Share Posted October 2, 2018 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. AlienStar 1 Link to comment Share on other sites More sharing options...
IAMK Posted October 2, 2018 Share Posted October 2, 2018 (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 October 2, 2018 by IAMK AlienStar 1 Link to comment Share on other sites More sharing options...
AlienStar Posted October 2, 2018 Author Share Posted October 2, 2018 (edited) 6 hours ago, 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. thanks so much you gave me the idea to continue Edited October 2, 2018 by AlienStar Link to comment Share on other sites More sharing options...
mikell Posted October 2, 2018 Share Posted October 2, 2018 15 hours ago, AlienStar said: but I can't do this in autoit 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) AlienStar 1 Link to comment Share on other sites More sharing options...
AlienStar Posted October 2, 2018 Author Share Posted October 2, 2018 1 hour ago, 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) Amazing Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now