Sign in to follow this  
Followers 0
bobheart

Take urls out of bookmarks

7 posts in this topic

How would I take just the url part out of my bookmark.html page ?

And dump it in to a txt file so all it had was the url's not any of the html code ?

$file = FileOpen("bookmark.html", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in 1 character at a time until the EOF is reached
While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Char read:", $chars)
Wend

FileClose($file)

Share this post


Link to post
Share on other sites



Reading a character at a time is a little slow, no?

Read the whole file into a variable at once, StringSplit it by @CRLF, then iterate through each element in the array looking for an HREF. If you find an HREF, then skip the next 2 characters, then the URL will continue until you find a quotation mark (Hint: StringTrimLeft() from the HREF's position + 6 (I think), then find the position of the next quotation mark will give you the number of characters to extract using StringMid() or StringLeft()).

Share this post


Link to post
Share on other sites

Oh my that looks confusing . not sure how to even start .

Share this post


Link to post
Share on other sites

Thanks Larry , how would I dump that in to a txt file now ?

Share this post


Link to post
Share on other sites

Larry, that's not going to work. There are other attributes in one of FireFox's bookmark files. Since the URL is the only one we want, something like this is necessary:

Func DumpURLs( $szFile )
    $aLines = StringSplit( FileRead( $szFile , FileGetSize( $szFile ) ) , @LF )
    $szDump = ""
    $szHREF = '<a href='
    For $i = 1 to $aLines[0]
        $n = StringInStr( $aLines[$i] ,  $szHREF)
        If $n Then
            $aLines[$i] = StringTrimLeft($aLines[$i] , $n + StringLen($szHREF))
            $szDump =  $szDump & StringLeft( $aLines[$i] , StringInStr( $aLines[$i] , '"' ) - 1 ) & @CRLF
        EndIf
    Next
    Return $szDump
EndFunc

Share this post


Link to post
Share on other sites

Thanks Larry and Valik the last one Valik did I added it to yours and it works fine now .. thank you both ..

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