New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markup-parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markup-parser

Parse JS variables from HTML markup

  • 0.1.3
  • PyPI
  • Socket score

Maintainers
1

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!

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc