bobheart Posted July 25, 2004 Share Posted July 25, 2004 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) Link to comment Share on other sites More sharing options...
Valik Posted July 25, 2004 Share Posted July 25, 2004 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 More sharing options...
bobheart Posted July 25, 2004 Author Share Posted July 25, 2004 Oh my that looks confusing . not sure how to even start . Link to comment Share on other sites More sharing options...
bobheart Posted July 26, 2004 Author Share Posted July 26, 2004 Thanks Larry , how would I dump that in to a txt file now ? Link to comment Share on other sites More sharing options...
Valik Posted July 26, 2004 Share Posted July 26, 2004 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 Link to comment Share on other sites More sharing options...
bobheart Posted July 26, 2004 Author Share Posted July 26, 2004 Thanks Larry and Valik the last one Valik did I added it to yours and it works fine now .. thank you both .. Link to comment Share on other sites More sharing options...
trids Posted July 26, 2004 Share Posted July 26, 2004 And here's another way to peel the potato 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