flyingwolfox / netscape-bookmarks-file-parser Goto Github PK
View Code? Open in Web Editor NEWParser and creator for Netscape Bookmarks file format that is used when exporting bookmarks from browsers
License: MIT License
Parser and creator for Netscape Bookmarks file format that is used when exporting bookmarks from browsers
License: MIT License
This project's documentation is very good, however, I had a lot of trouble figuring out how to use the parser's methods. Eventually I found the line The folder tree can be navigated using the "." notation.
and figured out what was meant by it. I think having a simple, short text block in the README.md
demonstrating what is meant by that line would make it much more clear.
This may be too much.
from NetscapeBookmarksFileParser import *
from NetscapeBookmarksFileParser import parser
with open('bookmarks.html') as file:
bookmarks = NetscapeBookmarksFile(file).parse()
bookmarks.bookmarks.items.<desiredContent>
In The BookmarkFolder class section of the wiki lists entries
as one of the available variables. This is not true.
Firefox supports associating shortcut keywords with bookmarks. When the keyword is entered in the top bar that's associated with a bookmark, Firefox will automatically navigate to that bookmarked page. This field is currently ignored.
<DT><A HREF="http://bookmarkurl/" ADD_DATE="1705518475" LAST_MODIFIED="1705518610" SHORTCUTURL="bookmarkmenukeyword" TAGS="BookmarkMenuTag">BookmarkMenuName</A>
Hi,
An attempt at parsing results in this error:
>>> ks = NetscapeBookmarksFile('static/html/example.html').parse()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/spaces/python/fastapi-sidebar/.venv/lib/python3.9/site-packages/NetscapeBookmarksFileParser/
parser.py", line 228, in parse
while '<' not in lines[line_num]:
IndexError: list index out of range
>>>
Exactly the same error reported here.
line_num = 0
file = netscape_bookmarks_file
lines = netscape_bookmarks_file.html.splitlines()
while '<' not in lines[line_num]: # Line 228
line_num += 1
The idea is not quite clear to me, but this conditional increment is obviously dangerous.
A reasonably short example, which produces this error can be found here
I am having the same error on a file exported from the Google Bookmarks service, which expires September 30. It's visible in the browser, so should be salvageable.
UPD
Oh, I'm sorry. It should have been
>>> with open('static/html/example.html') as file:
... ks = NetscapeBookmarksFile(file).parse()
...
>>> ks
<NetscapeBookmarksFileParser.NetscapeBookmarksFile object at 0x7f3de67d8040>
What can I do with this ks
object? Can I make a dictionary of it?
Hi,
Could you please provide an example of basic usage for parsing a file. This is the code that I'm using, but I get a "list index out of range" error when trying to run the parse function :
from NetscapeBookmarksFileParser import *
from NetscapeBookmarksFileParser import parser
...
file = NetscapeBookmarksFile("test.html")
bookmarks = parser.parse(file)
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.