Piyush Posted November 19, 2010 Share Posted November 19, 2010 <a href="http://link.songs.pk/song1.php?songid=7995"> No Problem</a><a href="http://link.songs.pk/song1.php?songid=7996"> Shakira</a>these are the example of the html written on a page....i need to extract the link and the text of the link..(for e.g. http://link.songs.pk/song1.php?songid=7995, No problem) with the help....regex....i have tried a lot bt was not able to extract..please help thx..... [font="Comic Sans MS"][size="7"]Piyush.....[/size][/font][font="Palatino Linotype"][size="2"]Some Of My Scripts...Cool Font Generator Train Searcher and Tracer[/size][/font] Link to comment Share on other sites More sharing options...
Realm Posted November 19, 2010 Share Posted November 19, 2010 (edited) Hello Piyush, I wrote a small example for you, however, this will grab anything that has similar link formats from source code you are reading from. I suggest finding a way to define it better or, in a step before this one, try to grab the block of code that you need to read this from. I included a way to convert the information into a 2D array, to give the rest of your script an easier way to obtain the information. However, it could have errors depending on the other links within the source. test, play, and see what you can come up with. #include <Array.au3> Local $source = '<a href="http://link.songs.pk/song1.php?songid=7995">No Problem</a>' & @CRLF _ & '<a href="http://link.songs.pk/song1.php?songid=7996">Shakira</a>' Local $sre = StringRegExp($source,'\<a href\=\"(.*?)\"\>(.*?)\<\/a\>',3) ;This will grab both the link and the text you need. ;Here I include a way to convert that information into a 2D array ;$new_Array[n][0] will contain the link ;$new_Array[n][1] will contain the text $row = (UBound($sre))/2 Local $new_Array[$row][2] $dim = 0 For $s = 0 To UBound($sre)-2 Step 2 $new_Array[$dim][0] = $sre[$s] $new_Array[$dim][1] = $sre[$s + 1] $dim +=1 Next _ArrayDisplay($new_Array) Enjoy! Realm Edit: Fixed a typo in my code. Edited November 19, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Piyush Posted November 20, 2010 Author Share Posted November 20, 2010 hey! thx.... [font="Comic Sans MS"][size="7"]Piyush.....[/size][/font][font="Palatino Linotype"][size="2"]Some Of My Scripts...Cool Font Generator Train Searcher and Tracer[/size][/font] Link to comment Share on other sites More sharing options...
Realm Posted November 20, 2010 Share Posted November 20, 2010 hey! thx....My pleasure, I had the time My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 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