Posts your html to telegra.ph blogging service
Project description
Python html to telegra.ph poster
Simple python function to post plain html text to https://telegra.ph/.
Telegra.ph allows <a>, <blockquote>, <br>, <em>, <figure>, <h3>, <h4>, <img>, <p>, <strong>,
elements.
It also supports embedded youtube and vimeo iframe tags.
About telegram telegra.ph service https://telegram.org/blog/instant-view
Requirements
- lxml
- requests
- requests_toolbelt
Installation
pip install html-telegraph-poster
Usage
>>> from html_telegraph_poster import TelegraphPoster
>>> t = TelegraphPoster()
>>> t.create_api_token('Elon Musk', 'Elon', 'https://www.spacex.com/') # second and third params are optional
{'access_token': '9f3bab568f*************', 'auth_url': 'https://edit.telegra.ph/auth/HFYo***********', 'author_name': 'Elon', 'short_name': 'Elon Musk', 'author_url': 'https://www.spacex.com/'}
>>> t.post(title='Just another funny joke', author='by me', text='<blockquote>Really hard way</blockquote>')
{'url': 'https://telegra.ph/Just-another-funny-joke-12-05', 'path': 'Just-another-funny-joke-12-05', 'tph_uuid': '4gFlYHCFiIBAxk***********', 'page_id': 'a38*************'}
# We can modify this article later
>>> t.edit(text=t.text + '<p>some text at the end</p>')
{'url': 'https://telegra.ph/Just-another-funny-joke-12-05', 'path': 'Just-another-funny-joke-12-05', 'tph_uuid': '4gFlYHCF*********', 'page_id': 'a381b2********'}
Generate persistent access token
Actually it's a good idea to generate access token and put it inside environment variables.
This command will generate .env file or append TELEGRAPH_ACCESS_TOKEN at the end of it.
Note: script will not set environment variable. You can use python-dotenv,
set it manually or hardcode it when call TelegraphPoster(access_token='access_token_string')
python -m html_telegraph_poster.create_account "Elon Musk" "Elon" "https://www.spacex.com/"
Uploading images
from html_telegraph_poster.upload_images import upload_image
# upload file
upload_image("file_path.jpg")
#upload url
upload_image("http://example.com/img.png")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file html_telegraph_poster-0.1.51.tar.gz
.
File metadata
- Download URL: html_telegraph_poster-0.1.51.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54e83461a9b0ba9a0fd0a221997ac3cc3b663a9a8a60f273367e51aecd3de9c9 |
|
MD5 | eb83b7ba8a247552a71901df995259ea |
|
BLAKE2b-256 | eff0329e22d3364f569272560c7ff2527c3852362aab89cd289c0a89bdaff6db |
File details
Details for the file html_telegraph_poster-0.1.51-py3-none-any.whl
.
File metadata
- Download URL: html_telegraph_poster-0.1.51-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c81fec6d568ea4264de1c10ed83b4f2e44a0e1a760160c5abda5bc93eb85ce0 |
|
MD5 | 33c8a5f1c0494d05c70d25547ecfe77c |
|
BLAKE2b-256 | 8028da1b6cc3dfdc671c95afa46182acaf1014e332f90502e86e54ec5b2f0ed5 |
File details
Details for the file html_telegraph_poster-0.1.51-py2-none-any.whl
.
File metadata
- Download URL: html_telegraph_poster-0.1.51-py2-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4232136ff1711f6b1ee3f37e19c143e5bd648cf19dec853a4d64936692fba0e1 |
|
MD5 | 8016476bee6349eabf36a4589bf1f228 |
|
BLAKE2b-256 | 36733a83e8046daafbf07e3e82f6fe3459c079cf7cabdc4541f4ded98974f3fd |