Skip to main content

Markup Parser

Extract JS variables content from HTML markup

Codecov Build Status Versions Release

ENG

RU

Installation

pip install markup-parser

Usage

Parse variable from html text:

Test content

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
    </head>
    <body>
    
    </body>
    <script>
        let test_variable = 'You found me';
    </script>
</html>
import requests
from markup_parser import var_from_html

# Fetch html content by get request
html_text = requests.get('http://test.html').text
var_from_html(html_text, 'test_variable')

# Parse from file
var_from_html(open('test.html').read(), 'test_variable')

# >>> You found me

Parse variable from url:

* This variant not recommended if you need to specify custom headers, this feature may be added in future release

Test content

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
    </head>
    <body>
    
    </body>
    <script>
        let test_variable = 'You found me again!';
    </script>
</html>
from markup_parser import var_from_url

var_from_url('http://test.page', 'test_variable')

# >>> You found me again!

RU

ENG

Установка

pip markup-parser

Примеры использования

Получить значение переменной из html разметки:

Пример html страницы

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
    </head>
    <body>
    
    </body>
    <script>
        let test_variable = 'You found me';
    </script>
</html>
import requests
from markup_parser import var_from_html

# Получить html разметку с помощью get запроса
html_text = requests.get('http://test.html').text
var_from_html(html_text, 'test_variable')

# Прочитать из файла
var_from_html(open('test.html').read(), 'test_variable')

# >>> You found me

Получить значение переменной по ссылке:

* На данный момент этот вариант не рекомендуется если вам необходимы специфичные заголовки, эта функция может появтися в будущих релизах

Пример html страницы

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
    </head>
    <body>
    
    </body>
    <script>
        let test_variable = 'You found me again!';
    </script>
</html>
from markup_parser import var_from_url

var_from_url('http://test.page', 'test_variable')

# >>> You found me again!

Metadata

Release files for markup-parser 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markup-parser 0.1.3
File Size Uploaded
markup_parser-0.1.3.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markup-parser 0.1.3
File Interpreter ABI Platform
markup_parser-0.1.3-cp39-cp39-macosx_12_0_arm64.whl CPython 3.9 CPython 3.9 macOS 12.0+ ARM64 Details

Total release size: 7.5 MB

Release files / markup_parser-0.1.3.tar.gz

Download URL markup_parser-0.1.3.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c3b3b193fc6b63952bcece930fb9f9b4a414773d8cc4f458f97a13582fba677c
BLAKE2b-256 checksum
How to use checksums
b64be66b2d6efc8127ae6ab7c9d17b7916e5f5149ce5ae0b130c39848debdda2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.18

Release files / markup_parser-0.1.3-cp39-cp39-macosx_12_0_arm64.whl

Download URL markup_parser-0.1.3-cp39-cp39-macosx_12_0_arm64.whl
Size 7.5 MB
Tags CPython 3.9 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
aaa9a841861788b9251a1cd602c6008038a4d81d608c03dfe606c10300d34b9f
BLAKE2b-256 checksum
How to use checksums
c0c2b1c2c971737dc5aa472f929c94cbcfcb92eed625126418d54df8f10d7f5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page