Smigacznr1 Posted July 18, 2011 Share Posted July 18, 2011 In code: <a href="/watch?v=GcOAv1M3Kn8" >flower_trans_RGB_PAL</a> </div> <span class="vm-video-info"> 18 lipiec 2011, 02:24 (PDT) <span class="vm-separator">|</span> <div class="yt-uix-hovercard vm-inline"> <span class="vm-video-desc yt-uix-hovercard-target">Uploaded with Free Video Converter from Freemake http://www.fr...</span> <span class="yt-uix-hovercard-content">Uploaded with Free Video Converter from Freemake http://www.freemake.com/free_video_converter/</span> </div> </span> <span class="vm-video-info"> </span> <span class="vm-video-info"> <span class="yt-uix-button-group"><button name="66447398811" onclick=";return false;" type="button" class="start vm-playlist-edit-video yt-uix-button yt-uix-button-short" role="button" aria-pressed="false"><span class="yt-uix-button-content">Edytuj</span></button> I need to find title (flower_trans_RGB_PAL). I have: $tytul = _StringBetween($sHTML,'" >','</a>([?s]*)Uploaded with Free Video Converter') and it's getting me empty string. I don't know why. ?s - all chars with new line * - repeating What's wrong? Link to comment Share on other sites More sharing options...
jchd Posted July 18, 2011 Share Posted July 18, 2011 (edited) You're confusing _StringBetween and StringRegExp!Read help file again for these two functions.Then your vision of regexp patterns is poetic at best and doesn't fit PCRE Regular Expression semantic.Try:$res = StringRegExp($html, ">([^<]*?)</a>", 3)EDIT: right, the cut & paste went astray. Sorry Edited July 18, 2011 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Golabius Posted July 18, 2011 Share Posted July 18, 2011 try it: $ary = StringRegExp($sHTML,'<a href="/watch\?v=.*?" >(.*?)</a>',3) for $i = 0 to UBound($ary) - 1 msgbox(0, "RegExp", $ary[$i]) Next Link to comment Share on other sites More sharing options...
Smigacznr1 Posted July 18, 2011 Author Share Posted July 18, 2011 try it: $ary = StringRegExp($sHTML,'<a href="/watch\?v=.*?" >(.*?)</a>',3) for $i = 0 to UBound($ary) - 1 msgbox(0, "RegExp", $ary[$i]) Next Don't work. No msgbox... I'm lost now. Could someone write this whole function? I'm learning autoit for few days. I'm learning best on samples so I'll be grateful for whole function. I have no idea how to do that. :/ Link to comment Share on other sites More sharing options...
jchd Posted July 18, 2011 Share Posted July 18, 2011 This works on the example you gave: $shtml = ' ... whatever before ... <a href="/watch?v=GcOAv1M3Kn8" >flower_trans_RGB_PAL</a> ... whatever follows ... ' $ary = StringRegExp($sHTML, '<a href="/watch\?v=.*?" >(.*?)</a>', 3) For $i = 0 To UBound($ary) - 1 msgbox(0, "RegExp", $ary[$i]) Next Now if your actual data departs from your example, then the pattern may have to be adjusted. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Smigacznr1 Posted July 18, 2011 Author Share Posted July 18, 2011 This works on the example you gave: $shtml = ' ... whatever before ... <a href="/watch?v=GcOAv1M3Kn8" >flower_trans_RGB_PAL</a> ... whatever follows ... ' $ary = StringRegExp($sHTML, '<a href="/watch\?v=.*?" >(.*?)</a>', 3) For $i = 0 To UBound($ary) - 1 msgbox(0, "RegExp", $ary[$i]) Next Now if your actual data departs from your example, then the pattern may have to be adjusted. With your example I have no msgbox... What I need exactly to do. I need to check if in HTML is description "Uploaded with Free Video Converter" if yes check what is name of video with above description and find name of button 'Edytuj' (html code I posted first on this topic). And here is some difficult because we don't know leght of code between title of video and description and between description and name of button 'Edytuj'. Only one constant string what we know always is part of description ('Uploaded with Free Video Converter'). That's why it's so hard for me. I'm trying to write something like this for first time and I stuck... :/ I already have: Func zamykanie() if $success = True Then $oIE = _IECreate ("https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Dpl_PL%26next%3D%252F&hl=pl_PL<mpl=sso", 0, 1, 1, 0) Send("login{TAB}pass{ENTER}") _IELoadWait ($oIE) _IENavigate ($oIE, "http://www.youtube.com/my_videos?feature=mhee") _IELoadWait ($oIE) $sHTML = _IEBodyReadHTML ($oIE) If StringInStr($sHTML,"Uploaded with Free Video Converter") Then ;something to do here endif EndFunc Link to comment Share on other sites More sharing options...
jchd Posted July 18, 2011 Share Posted July 18, 2011 I insist on being positive: with the untouched example the msgbox pops up. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Smigacznr1 Posted July 18, 2011 Author Share Posted July 18, 2011 I insist on being positive: with the untouched example the msgbox pops up. expandcollapse popup#include <IE.au3> #Include <String.au3> #Include <Array.au3> AutoItSetOption("WinTitleMatchMode", 2) Global $success = False completed() Func completed() $i=0 For $i=0 to 1 If WinExists("Uploading completed") Then If WinExists("Success") Then $success = True zamykanie() endif endif $i=0 ContinueLoop next EndFunc Func zamykanie() if $success = True Then $oIE = _IECreate ("https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Dpl_PL%26next%3D%252F&hl=pl_PL<mpl=sso", 0, 1, 1, 0) Send("login{TAB}pass{ENTER}") _IELoadWait ($oIE) _IENavigate ($oIE, "http://www.youtube.com/my_videos?feature=mhee") _IELoadWait ($oIE) $sHTML = _IEBodyReadHTML ($oIE) If StringInStr($sHTML,"Uploaded with Free Video Converter") Then $ary = StringRegExp($sHTML, '<a href="/watch\?v=.*?" >(.*?)</a>', 3) For $i = 0 To UBound($ary) - 1 MsgBox(0, "RegExp", $ary[$i]) Next endif EndFunc So what's wrong here? Link to comment Share on other sites More sharing options...
jchd Posted July 18, 2011 Share Posted July 18, 2011 Your URL! Add COM error function. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Smigacznr1 Posted July 18, 2011 Author Share Posted July 18, 2011 Your URL!Add COM error function.OK. I'm reading about COM and objactions. Coul you tell which url is wrong and why? 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