Giter VIP home page Giter VIP logo

flyingwolfox / netscape-bookmarks-file-parser Goto Github PK

View Code? Open in Web Editor NEW
40.0 4.0 10.0 110 KB

Parser and creator for Netscape Bookmarks file format that is used when exporting bookmarks from browsers

License: MIT License

Python 92.85% HTML 7.15%
netscape-bookmark exporting-bookmarks parser parse-netscape-bookmarks-file-1 parse-netscape-bookmarks-file parse-netscape parse-bookmarks bookmarks netscape netscape-bookmark-file

netscape-bookmarks-file-parser's People

Contributors

deepsourcebot avatar flyingwolfox avatar harmtemolder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

netscape-bookmarks-file-parser's Issues

Documentation: README.md Clarification and Wiki Correction

README.md

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.

Example

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>

Wiki Changes

In The BookmarkFolder class section of the wiki lists entries as one of the available variables. This is not true.

Feature Request: Support for "SHORTCUTURL" as producted by Firefox

Description

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.

Example Firefox Export

<DT><A HREF="http://bookmarkurl/" ADD_DATE="1705518475" LAST_MODIFIED="1705518610" SHORTCUTURL="bookmarkmenukeyword" TAGS="BookmarkMenuTag">BookmarkMenuName</A>

List index out of range

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 228:

    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?

Fail gracefully

Make the parser more fail safe, adding checks instead of parsing the file blindly.
Also have better error messages: #3
Checks needs to make the code safer: #6

Usage

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.