Sign in to follow this  
Followers 0
faustf

StringRegExp where is my error ?

9 posts in this topic

hi guy  

i have  this  web page  i attacched

and  use  this  code

Local $aArray_Descrizione_prodotti = StringRegExp($sText, '(?i)<div class="mostro" abp=".+?">\h*([^<]+)</strong>&nbsp; </div>', $STR_REGEXPARRAYGLOBALMATCH) ; descrizione breve

descrizione-short.html

Share this post


Link to post
Share on other sites



Please post a runnable code and an example of expected result

Share this post


Link to post
Share on other sites

; Script Start - Add your code below here
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <InetConstants.au3>
#include <WinAPI.au3>
#include <WinAPIsysinfoConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <INet.au3>
#include <Excel.au3>
#include <File.au3>



$sHTML_1_level = ("E:\_GROSSITI-GRAB\Espri_temp\descrizione-short.html")


$aArray = StringRegExp($sHTML_1_level, "btn btn-small gradient eleCat.+?<a[^>]+>\h*([^<]+)</a>", 3)


For $i_CodP = 0 To UBound($aArray) - 1
    MsgBox(0,'',$aArray[$i_CodP])

    Next

Share this post


Link to post
Share on other sites

Well, doing a quick search of your attached file, the word eleCat appears nowhere in the file.  So it couldn't find it even if you had loaded the file into a variable properly.  That's the bigger problem--you need to use FileRead to load the file into the variable first.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

o sorry i copy  not good line  

Local $aArray_Descrizione_prodotti = StringRegExp($sText, '(?i)<div class="mostro" abp=".+?">\h*([^<]+)</strong>&nbsp; </div>', $STR_REGEXPARRAYGLOBALMATCH) ; descrizione breve

this is a  correct  ,  but not  go  :( 

Edited by faustf

Share this post


Link to post
Share on other sites

Nice. And what about an example of expected result ?

Share this post


Link to post
Share on other sites

 i want if  possible  (not  only  one )

Utilizzo: <strong abp="291">Home music</strong>&nbsp;Potenza output per canale: <strong abp="292">140 W</strong>&nbsp;Colore primario: <strong abp="293">Nero</strong>&nbsp;Potenza W RMS : <strong abp="294">140 W</strong>&nbsp;Impedenza: <strong abp="295">4 Ohm</strong>&nbsp;N° Canali: <strong abp="296">2</strong>&nbsp;Collegamento iPod: <strong abp="297">No</strong>&nbsp;                    </div>

without  html code :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Something like this then...

But all this seems really hazardous

$sText = FileRead("descrizione-short.html")
Local $res = StringRegExp($sText, '(?is)<div class="mostro" abp="\d+">\s*(.*?)</strong>&nbsp;\h*</div>', 3) ; descrizione breve

 _ArrayDisplay($res)

For $i = 0 to UBound($res)-1
   $str = StringRegExpReplace($res[$i], '<strong.*?>', "")
   $str = StringRegExpReplace($str, '</strong>&nbsp;', @crlf)
   Msgbox(0,"", $str)
Next
Edited by mikell
1 person likes this

Share this post


Link to post
Share on other sites

go perfect  thankzzz so much :D

Share this post


Link to post
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
Sign in to follow this  
Followers 0