File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1- """Parse types and methods from the Telegram Bot API HTML page (tg.html) .
1+ """Parse types and methods from the Telegram Bot API page.
22
3- Outputs two JSON files under compiler/api/:
3+ Fetches https://core.telegram.org/bots/api and outputs two JSON files
4+ under compiler/api/:
45 - bot_api_types.json — all Bot API types
56 - bot_api_methods.json — all Bot API methods
67"""
1011from html import unescape
1112from html .parser import HTMLParser
1213from pathlib import Path
14+ from urllib .request import urlopen
1315
1416BASE_DIR = Path (__file__ ).parent
15- HTML_PATH = BASE_DIR / "tg.html "
17+ API_URL = "https://core.telegram.org/bots/api "
1618API_DIR = BASE_DIR / "api"
1719
1820# ---------- HTML table extractor ----------
@@ -309,7 +311,8 @@ def _get_section(heading_line: int) -> str:
309311
310312
311313def main ():
312- html = HTML_PATH .read_text (encoding = "utf-8" )
314+ with urlopen (API_URL ) as resp :
315+ html = resp .read ().decode ("utf-8" )
313316 types , methods = parse (html )
314317
315318 API_DIR .mkdir (parents = True , exist_ok = True )
You can’t perform that action at this time.
0 commit comments