Jump to content

Take urls out of bookmarks

Recommended Posts

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.")

; 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)

Link to comment
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()).

Link to comment
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
    Return $szDump
Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...