{"id":13461872,"url":"https://github.com/mercuree/html-telegraph-poster","last_synced_at":"2025-12-14T06:46:00.579Z","repository":{"id":48588542,"uuid":"75470219","full_name":"mercuree/html-telegraph-poster","owner":"mercuree","description":"Python html to telegra.ph poster (telegram article service)","archived":false,"fork":false,"pushed_at":"2023-07-19T03:37:27.000Z","size":153,"stargazers_count":103,"open_issues_count":4,"forks_count":28,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-24T18:40:37.019Z","etag":null,"topics":["python","telegram","telegraph"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mercuree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-12-03T11:41:22.000Z","updated_at":"2025-02-16T05:16:25.000Z","dependencies_parsed_at":"2024-02-17T10:44:53.521Z","dependency_job_id":null,"html_url":"https://github.com/mercuree/html-telegraph-poster","commit_stats":{"total_commits":183,"total_committers":2,"mean_commits":91.5,"dds":"0.36612021857923494","last_synced_commit":"7212225e28a0206803c32e67d1185bbfbd1fc181"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercuree%2Fhtml-telegraph-poster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercuree%2Fhtml-telegraph-poster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercuree%2Fhtml-telegraph-poster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercuree%2Fhtml-telegraph-poster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mercuree","download_url":"https://codeload.github.com/mercuree/html-telegraph-poster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245372193,"owners_count":20604487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","telegram","telegraph"],"created_at":"2024-07-31T12:00:25.871Z","updated_at":"2025-12-14T06:45:55.535Z","avatar_url":"https://github.com/mercuree.png","language":"Python","funding_links":[],"categories":["Examples"],"sub_categories":["Python"],"readme":"[![build](https://github.com/mercuree/html-telegraph-poster/actions/workflows/python-package.yml/badge.svg)](https://github.com/mercuree/html-telegraph-poster/actions/workflows/python-package.yml)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/html-telegraph-poster?master)](https://pypi.org/project/html-telegraph-poster/)\n\n# Python html to telegra.ph poster\n\nSimple python function to post plain html text to https://telegra.ph/.\nTelegra.ph allows `\u003ca\u003e, \u003cblockquote\u003e, \u003cbr\u003e, \u003cem\u003e, \u003cfigure\u003e, \u003ch3\u003e, \u003ch4\u003e, \u003cimg\u003e, \u003cp\u003e, \u003cstrong\u003e, ` elements.\nIt also supports embedded youtube and vimeo iframe tags.\n\nAbout telegram telegra.ph service https://telegram.org/blog/instant-view\n\n## Requirements\n* lxml\n* requests\n* requests_toolbelt\n\n## Installation\n```Shell\npip install html-telegraph-poster\n```\n\n## Usage\n```python\n\u003e\u003e\u003e from html_telegraph_poster import TelegraphPoster\n\u003e\u003e\u003e t = TelegraphPoster(use_api=True)\n\u003e\u003e\u003e t.create_api_token('Elon Musk', 'Elon', 'https://www.spacex.com/') # second and third params are optional\n{'access_token': '9f3bab568f*************', 'auth_url': 'https://edit.telegra.ph/auth/HFYo***********', 'author_name': 'Elon', 'short_name': 'Elon Musk', 'author_url': 'https://www.spacex.com/'}\n\u003e\u003e\u003e t.post(title='Just another funny joke', author='by me', text='\u003cblockquote\u003eReally hard way\u003c/blockquote\u003e')\n{'path': 'Just-another-funny-joke-06-05-4', 'url': 'http://telegra.ph/Just-another-funny-joke-06-05-4'}\n```\n##### Use graph.org instead of telegra.ph\n```python\n\u003e\u003e\u003e t = TelegraphPoster(use_api=True, telegraph_api_url='https://api.graph.org')\n```\n##### We can modify this article later:\n```python\n\u003e\u003e\u003e t.edit(text=t.text + '\u003cp\u003esome text at the end\u003c/p\u003e')\n{'path': 'Just-another-funny-joke-06-05-4', 'url': 'http://telegra.ph/Just-another-funny-joke-06-05-4'}\n```\n##### Modify page created earlier:\n```python\n\u003e\u003e\u003e t.edit(text=\"\u003cp\u003enew text\u003c/p\u003e\", path='/Another-one-page-06-05')\n{'path': 'Another-one-page-06-05', 'url': 'http://telegra.ph/Another-one-page-06-05'}\n```\n\n## Generate persistent access token\nActually it's a good idea to generate access token and put it inside environment variables.\nThis command will generate .env file or append  TELEGRAPH_ACCESS_TOKEN at the end of it.\nNote: script will not set environment variable. You can use [python-dotenv](https://github.com/theskumar/python-dotenv),\nset it manually or hardcode it when call `TelegraphPoster(access_token='access_token_string')`\n```Shell\npython -m html_telegraph_poster.create_account \"Elon Musk\" \"Elon\" \"https://www.spacex.com/\"\n```\n\n## Uploading images\n```python\n\nfrom html_telegraph_poster.upload_images import upload_image\n\n# upload file\nupload_image(\"file_path.jpg\")\n\n# upload url\nupload_image(\"http://example.com/img.png\")\n\n# setting request and response timeout\nupload_image(\"http://example.com/img.png\", get_timeout=(5, 5), upload_timeout=(5, 5))\n\n```\n## Utils module\nUtils module provides ability to make some pre-process steps before document is passed to the converter.\n#### Uploading all images to the telegra.ph\n```python\nfrom html_telegraph_poster.utils import DocumentPreprocessor\n\ndp = DocumentPreprocessor(html_string)\ndp.upload_all_images()\ndp.get_processed_html() # this should return html string with uploaded and replaced image urls\n```\nOptionally you can pass base_url if the document contains images with relative paths\n```python\ndp.upload_all_images(base_url='https://example.com')\ndp.get_processed_html() \n``` ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmercuree%2Fhtml-telegraph-poster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmercuree%2Fhtml-telegraph-poster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmercuree%2Fhtml-telegraph-poster/lists"}