vSSC Posted September 6, 2016 Share Posted September 6, 2016 Hello. I have the following script: #include <string.au3> $Source = BinaryToString(InetRead('https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z', 1)) $FirstChunks = _StringBetween($Source, 'data-title="', '" data-set-video-id=') For $a In $FirstChunks ConsoleWrite($a & @CRLF) Next When i run it: sometimes i get the list of videos i'm intrested in, see run1, and sometimes i get bogus data, see run2. Any ideas why is this happening? RUN1: << >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Program Files (x86)\AutoIt3\Include\test2.au3" /UserParams +>11:07:34 Starting AutoIt3Wrapper v.16.612.1119.0 SciTE v.3.6.6.0 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\victor\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\victor\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files (x86)\AutoIt3 input:C:\Program Files (x86)\AutoIt3\Include\test2.au3 +>11:07:35 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Program Files (x86)\AutoIt3\Include\test2.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop AutoIt Scripting Tutorial 0 Introduction AutoIt Scripting Tutorial 1 Download and install AutoIt Scripting Tutorial 2 How to use functions and use the helpfile AutoIt Scripting Tutorial 3 Variables AutoIt Scripting Tutorial 4 Conditional IF/THEN and Function return values AutoIt Scripting Tutorial 5 Operators (eg simple math) AutoIt Scripting Tutorial 6 Loops (Do, While, For) AutoIt Scripting Tutorial 7 Arrays and a new For loop AutoIt Scripting Tutorial 8 Setting and using hotkeys AutoIt Scripting Tutorial 9 Automating Installers & Programs Part 1 AutoIt Scripting Tutorial 10A Automating Installers & Programs Part 2 AutoIt Scripting Tutorial 10B Automating Installers & Programs Part 2 AutoIt Scripting Tutorial 11.1 The GUI : Create visual menus with buttons AutoIt Scripting Tutorial 11.2 The GUI : Take user text input & manually set text AutoIt Scripting Tutorial 11.3 The GUI : Radio buttons & Check boxes to make choices AutoIt Scripting Tutorial 11.4 The GUI : Koda productivity tips and tricks Autoit Scripting Tutorial 11.5 The GUI : Creating Standard Menu Bars Autoit Scripting Tutorial 11.6 The GUI : Creating Tabs To Organize & Tidy Your Interface Autoit Scripting Tutorial 12.1 Settings : Basic Setting & Retrieving of Known Settings (ini Files) +>11:07:35 AutoIt3.exe ended.rc:0 +>11:07:35 AutoIt3Wrapper Finished. >Exit code: 0 Time: 2.478 >> RUN2 << "C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Program Files (x86)\AutoIt3\Include\test2.au3" /UserParams +>11:09:15 Starting AutoIt3Wrapper v.16.612.1119.0 SciTE v.3.6.6.0 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\victor\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\victor\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files (x86)\AutoIt3 input:C:\Program Files (x86)\AutoIt3\Include\test2.au3 +>11:09:15 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Program Files (x86)\AutoIt3\Include\test2.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop AutoIt Scripting Tutorial 0 Introduction"><td class="pl-video-handle "></td><td class="pl-video-index"></td><td class="pl-video-thumbnail"><span class="pl-video-thumb ux-thumb-wrap contains-addto"><a href="/watch?v=uz3bnrUKhW8&index=1&list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z" class="yt-uix-sessionlink" aria-hidden="true" data-sessionlink="ei=q3nOV7urN8SUWLHRksAP&feature=plpp_video&ved=CB0QxjQYACITCPusvYCl-s4CFUQKFgodsagE-Cj6LA" > <span class="video-thumb yt-thumb yt-thumb-72" > <span class="yt-thumb-default"> <span class="yt-thumb-clip"> <img onload=";__ytRIL(this)" aria-hidden="true" width="72" src="https://s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif" data-thumb="https://i.ytimg.com/vi/uz3bnrUKhW8/hqdefault.jpg?custom=true&w=120&h=90&jpg444=true&jpgq=90&sp=68&sigh=o-ecSqfI4DpBWYTEr3zvKQv4fh8" alt="" data-ytimg="1" > [.... similar site content ... ] <div class="pl-video-edit-options"></div></td></tr> <tr class="pl-video yt-uix-tile " data-set-video-id=" +>11:09:16 AutoIt3.exe ended.rc:0 +>11:09:16 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.402 >> Link to comment Share on other sites More sharing options...
pluto41 Posted September 6, 2016 Share Posted September 6, 2016 (edited) #include <array.au3> #include <string.au3> $Source = BinaryToString(InetRead('https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z', 1)) $FirstChunks = _StringBetween($Source, 'AutoIt Scripting Tutorial', '</a>', 1 ) ;_ArrayDisplay ( $FirstChunks ) ; Enable for debugging Local $array, $sRetString For $i = 1 to Ubound ( $FirstChunks ) - 1 Step 2 $array = StringRegExp ( $FirstChunks[$i], "([\s\.]|[[:alnum:]]|[\s\.])", 3 ) ; Return Numbers, Characters, Spaces and Points $sRetString = _ArrayToString ( $array ) ; Array to String Format $sRetString = StringStripWS ( "AutoIt Scripting Tutorial" & StringReplace ( $sRetString, "|", "" ), 1 ) ConsoleWrite( $sRetString ) Next Hi, just for fun i tried some things and came up with this. It gets the results every time i run the script. a more advanced AutoIT programmer can come up with much better solutions. But ok, it was also for me fun to play a bit with this. I noticed there are some weird chars in the array. Probably [enters-line feeds] or [carriage returns] they caused me some problems. Anyway hope this helps you and perhaps some other people come up with some better idea's. Edited September 6, 2016 by pluto41 Link to comment Share on other sites More sharing options...
mikell Posted September 7, 2016 Share Posted September 7, 2016 This should work in both cases _StringBetween($Source, 'data-title="', '"') 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