Last active
February 10, 2019 15:35
-
-
Save pedrohdz/ae48efdbe36f928800e3474ac0e243fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# pylint: disable=missing-docstring | |
from urllib import parse | |
import webbrowser | |
import requests | |
from bs4 import BeautifulSoup | |
BASE_URL = 'ithoughts://x-callback-url/makeMap?' | |
def main(): | |
url = 'https://www.toketaware.com/ithoughts-howto-x-callback-url' | |
parameters = process(url) | |
call = BASE_URL + parse.urlencode(parameters, quote_via=parse.quote) | |
# print(call) | |
webbrowser.open(call) | |
def process(url, path='/test/test', target=None, edit=None): | |
req = requests.get(url) | |
soup = BeautifulSoup(req.text, 'html.parser') | |
description = soup.p.text | |
title = soup.title.text | |
note = '# {}\n\n{}\n\n_[quick link]({})_'.format(title, description, url) | |
text = '# {}'.format(title) | |
data = { | |
'format': 'md', | |
'link': url, | |
'note': note, | |
'path': path, | |
'style': 'Chalkboard', | |
'text': text, | |
} | |
if target is not None: | |
data['target'] = target | |
if edit is not None: | |
data['edit'] = edit | |
return data | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment