Posts your html to telegra.ph blogging service
Project description
[![Build Status](https://travis-ci.org/mercuree/html-telegraph-poster.svg?branch=master)](https://travis-ci.org/mercuree/html-telegraph-poster)
# 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
```Shell
pip install html-telegraph-poster
```
## Usage
```python
>>> 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](https://github.com/theskumar/python-dotenv),
set it manually or hardcode it when call `TelegraphPoster(access_token='access_token_string')`
```Shell
python -m html_telegraph_poster.create_account "Elon Musk" "Elon" "https://www.spacex.com/"
```
## Uploading images
```python
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")
```
# 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
```Shell
pip install html-telegraph-poster
```
## Usage
```python
>>> 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](https://github.com/theskumar/python-dotenv),
set it manually or hardcode it when call `TelegraphPoster(access_token='access_token_string')`
```Shell
python -m html_telegraph_poster.create_account "Elon Musk" "Elon" "https://www.spacex.com/"
```
## Uploading images
```python
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
Close
Hashes for html_telegraph_poster-0.1.50.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 534aacf00c53023e08caf19c69666ea6798f1ba8557cb936bfaaf2d4ac0a5a9d |
|
MD5 | c3bbdaf3dc0454a3b69f9d0689fb6c94 |
|
BLAKE2b-256 | e939c0c8d2d8808db3719aea10a8e75ea839e1c17dab9b03e1d2f3803d040afa |
Close
Hashes for html_telegraph_poster-0.1.50-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 600ef813208abea46c06d15f19c05372a92ac8bc453d245eb43623e56c345703 |
|
MD5 | cfb3727199cff10cebf298d191471a8f |
|
BLAKE2b-256 | c69a1063e04b51d6559315703dc00531b0a77b5d0091fc36fea51b7594aebd03 |
Close
Hashes for html_telegraph_poster-0.1.50-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8129f75e2407c91eb3d9a358c51f540e9e603370721da37d5ab01fca683bf172 |
|
MD5 | 8fe2d591073b5a83b2df998886d96941 |
|
BLAKE2b-256 | c5b24c4d3e54f63ed474545b5b7a3ce7fb662e8f8891aa489e186520638eab51 |