From ec32a54fae509c206a657fef3ff617890335787d Mon Sep 17 00:00:00 2001 From: hexmind Date: Mon, 18 Apr 2016 18:55:48 +0200 Subject: [PATCH] fix user_agent name --- bookmarkstokml.py | 6 +++--- readme.md | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bookmarkstokml.py b/bookmarkstokml.py index fee9bfe..a20066b 100644 --- a/bookmarkstokml.py +++ b/bookmarkstokml.py @@ -15,7 +15,7 @@ import sys import time coords_in_content = re.compile('\/@(-?\d+\.\d+),(-?\d+\.\d+),') -mobile_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36' +user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36' filename = r'GoogleBookmarks.html' if(len(sys.argv) > 1): @@ -28,7 +28,7 @@ with open(filename) as bookmarks_file: doc = document_fromstring(data) class Browser(FancyURLopener): - version = mobile_agent + version = user_agent for label in doc.body.iterfind('dl/dt/h3'): labelName = label.text_content() @@ -62,7 +62,7 @@ for label in doc.body.iterfind('dl/dt/h3'): longitude = coords[1] except (AttributeError, IndexError): - print('[Coordinates not found] ' + str(coords) + ' Try to update "mobile_agent"') + print('[Coordinates not found: ' + str(coords) + '. Try to update "user_agent"]') continue print(latitude, longitude) diff --git a/readme.md b/readme.md index 9da118b..58b01df 100644 --- a/readme.md +++ b/readme.md @@ -5,8 +5,9 @@ Go to Google Bookmarks: https://www.google.com/bookmarks/ On the bottom left, click "Export bookmarks": https://www.google.com/bookmarks/bookmarks.html?hl=en Install script dependencies: -pip install simplekml lxml +pip3 install simplekml lxml -After downloading the html file, run this script on it to generate a KML file per bookmark label. +After downloading the html file, run this script on it to generate a KML file per bookmark label: +python3 bookmarkstokml.py GoogleBookmarks.html It's hacky and doesn't work on all of them, but it kinda works.