Skip to main content

Posts your html to blogging service

Project description

Build Status PyPI - Downloads

Python html to poster

Simple python function to post plain html text to allows <a>, <blockquote>, <br>, <em>, <figure>, <h3>, <h4>, <img>, <p>, <strong>, elements. It also supports embedded youtube and vimeo iframe tags.

About telegram service


  • lxml
  • requests
  • requests_toolbelt


pip install html-telegraph-poster


>>> from html_telegraph_poster import TelegraphPoster
>>> t = TelegraphPoster(use_api=True)
>>> t.create_api_token('Elon Musk', 'Elon', '') # second and third params are optional
{'access_token': '9f3bab568f*************', 'auth_url': '***********', 'author_name': 'Elon', 'short_name': 'Elon Musk', 'author_url': ''}
>>>'Just another funny joke', author='by me', text='<blockquote>Really hard way</blockquote>')
{'path': 'Just-another-funny-joke-06-05-4', 'url': ''}

# We can modify this article later
>>> t.edit(text=t.text + '<p>some text at the end</p>')
{'path': 'Just-another-funny-joke-06-05-4', 'url': ''}

# Modify page created earlier
>>> t.edit(text="<p>new text</p>", path='/Another-one-page-06-05')
{'path': 'Another-one-page-06-05', 'url': ''}

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" ""

Uploading images

from html_telegraph_poster.upload_images import upload_image

# upload file

# upload url

# setting request and response timeout
upload_image("", get_timeout=(5, 5), upload_timeout=(5, 5))

Utils module

Utils module provides ability to make some pre-process steps before document is passed to the converter.

Uploading all images to the

from html_telegraph_poster.utils import DocumentPreprocessor

dp = DocumentPreprocessor(html_string)
dp.get_processed_html() # this should return html string with uploaded and replaced image urls

Optionally you can pass base_url if the document contains images with relative paths


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html-telegraph-poster-0.4.0.tar.gz (14.7 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page