Skip to content

Instantly share code, notes, and snippets.

@4383
Created December 2, 2016 15:33
Show Gist options
  • Save 4383/1ccd5efe6d84d140da6c56689ac64a1e to your computer and use it in GitHub Desktop.
Save 4383/1ccd5efe6d84d140da6c56689ac64a1e to your computer and use it in GitHub Desktop.
Export manualy your google bookmarks and transform it to markdown format for hosting and versioning on github (quick and dirty)
# First export manualy your google bookmarks in place exported file in the same directory of this script
# After launch this script (python google-bookmarks-to-markdown-format.py) and have fun !
def run():
output = []
with open('GoogleBookmarks.html') as export:
html = export.readlines()
for line in html:
if 'H3' in line:
output.append('## {0}'.format(line[36:-6].capitalize()))
if 'A HREF' in line:
data = line.split()
link = data[1].replace('HREF="', '').replace('"', '')
text = line.replace(link, '')[43:-5].capitalize()
output.append('- [{0}]({1})'.format(text, link))
print(output)
with open('bookmarks.md', 'w+') as markdown:
markdown.write('\n'.join(output))
if __name__ == "__main__":
run()
@4383
Copy link
Author

4383 commented Dec 2, 2016

This is a quick and dirtty script for transform your google bookmarks on an file at markdown format.
After you can host it on github for beneficiate of versioning system and also of the gh-pages hosting.
Exemple of result (with my personal bookmarks)

@drmingdrmer
Copy link

I found another way to do this: copy HTML page, and paste in typora.
Typora is a great markdown editor that converts HTML to markdown when pasting and keeps most styles. 😄

@dimisjim
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment