Last active
February 15, 2019 15:11
-
-
Save pedrohdz/ea05b40620b352ca0f3b1d6306b75e63 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?' | |
class MyClass(): | |
"""Docstring for MyClass. """ | |
def __init__(self): | |
"""TODO: to be defined1. """ | |
hello | |
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