# Markup Parser
#### Extract JS variables content from HTML markup
[![Codecov](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/bigpe/markup-parser.svg?token=9PVJVxRxQ4uXFdey5v3k&branch=master)](https://travis-ci.com/bigpe/markup-parser)
[![Versions](https://img.shields.io/pypi/pyversions/markup-parser.svg)](https://pypi.org/project/markup-parser/)
[![Release](https://img.shields.io/github/release/bigpe/markup-parser.svg)](https://github.com/bigpe/markup-parser/releases)
### ENG
[RU](#ru)
## Installation
```shell
pip install markup-parser
```
## Usage
### Parse variable from html text:
Test content
```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>
```
```python
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
```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>
```
```python
from markup_parser import var_from_url
var_from_url('http://test.page', 'test_variable')
# >>> You found me again!
```
### RU
[ENG](#eng)
## Установка
```shell
pip markup-parser
```
## Примеры использования
### Получить значение переменной из html разметки:
Пример 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>
```
```python
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 страницы
```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>
```
```python
from markup_parser import var_from_url
var_from_url('http://test.page', 'test_variable')
# >>> You found me again!
```
Raw data
{
"_id": null,
"home_page": "https://github.com/bigpe/markup-parser",
"name": "markup-parser",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6.0",
"maintainer_email": null,
"keywords": "html, parse, markup, js, variables, rust",
"author": "Aleskandr Sokolov",
"author_email": "bigpewm@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b6/4b/e66b2d6efc8127ae6ab7c9d17b7916e5f5149ce5ae0b130c39848debdda2/markup_parser-0.1.3.tar.gz",
"platform": "any",
"description": "# Markup Parser\n#### Extract JS variables content from HTML markup\n[![Codecov](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Build Status](https://travis-ci.com/bigpe/markup-parser.svg?token=9PVJVxRxQ4uXFdey5v3k&branch=master)](https://travis-ci.com/bigpe/markup-parser)\n[![Versions](https://img.shields.io/pypi/pyversions/markup-parser.svg)](https://pypi.org/project/markup-parser/)\n[![Release](https://img.shields.io/github/release/bigpe/markup-parser.svg)](https://github.com/bigpe/markup-parser/releases)\n\n### ENG\n[RU](#ru)\n\n## Installation\n\n```shell\npip install markup-parser\n```\n\n## Usage\n\n### Parse variable from html text:\n\nTest content\n```html\n<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Test</title>\n </head>\n <body>\n \n </body>\n <script>\n let test_variable = 'You found me';\n </script>\n</html>\n```\n\n```python\nimport requests\nfrom markup_parser import var_from_html\n\n# Fetch html content by get request\nhtml_text = requests.get('http://test.html').text\nvar_from_html(html_text, 'test_variable')\n\n# Parse from file\nvar_from_html(open('test.html').read(), 'test_variable')\n\n# >>> You found me\n```\n\n### Parse variable from url:\n\n_* This variant not recommended if you need to specify custom headers, this feature may be added in future release_\n\nTest content\n```html\n<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Test</title>\n </head>\n <body>\n \n </body>\n <script>\n let test_variable = 'You found me again!';\n </script>\n</html>\n```\n\n```python\nfrom markup_parser import var_from_url\n\nvar_from_url('http://test.page', 'test_variable')\n\n# >>> You found me again!\n```\n\n### RU\n[ENG](#eng)\n\n## \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\n\n```shell\npip markup-parser\n```\n\n## \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\n\n### \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u0437 html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438:\n\n\u041f\u0440\u0438\u043c\u0435\u0440 html \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b\n```html\n<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Test</title>\n </head>\n <body>\n \n </body>\n <script>\n let test_variable = 'You found me';\n </script>\n</html>\n```\n\n```python\nimport requests\nfrom markup_parser import var_from_html\n\n# \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e get \u0437\u0430\u043f\u0440\u043e\u0441\u0430\nhtml_text = requests.get('http://test.html').text\nvar_from_html(html_text, 'test_variable')\n\n# \u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430\nvar_from_html(open('test.html').read(), 'test_variable')\n\n# >>> You found me\n```\n\n### \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435:\n\n_* \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0442\u0438\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0440\u0435\u043b\u0438\u0437\u0430\u0445_\n\n\u041f\u0440\u0438\u043c\u0435\u0440 html \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b\n```html\n<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Test</title>\n </head>\n <body>\n \n </body>\n <script>\n let test_variable = 'You found me again!';\n </script>\n</html>\n```\n\n```python\nfrom markup_parser import var_from_url\n\nvar_from_url('http://test.page', 'test_variable')\n\n# >>> You found me again!\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parse JS variables from HTML markup",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/bigpe/markup-parser"
},
"split_keywords": [
"html",
" parse",
" markup",
" js",
" variables",
" rust"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c0c2b1c2c971737dc5aa472f929c94cbcfcb92eed625126418d54df8f10d7f5f",
"md5": "c73b70f468ca2a18943df2821201862f",
"sha256": "aaa9a841861788b9251a1cd602c6008038a4d81d608c03dfe606c10300d34b9f"
},
"downloads": -1,
"filename": "markup_parser-0.1.3-cp39-cp39-macosx_12_0_arm64.whl",
"has_sig": false,
"md5_digest": "c73b70f468ca2a18943df2821201862f",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.6.0",
"size": 7471273,
"upload_time": "2024-06-02T09:48:02",
"upload_time_iso_8601": "2024-06-02T09:48:02.669031Z",
"url": "https://files.pythonhosted.org/packages/c0/c2/b1c2c971737dc5aa472f929c94cbcfcb92eed625126418d54df8f10d7f5f/markup_parser-0.1.3-cp39-cp39-macosx_12_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b64be66b2d6efc8127ae6ab7c9d17b7916e5f5149ce5ae0b130c39848debdda2",
"md5": "69c2326df87535dab38449d54154a8a3",
"sha256": "c3b3b193fc6b63952bcece930fb9f9b4a414773d8cc4f458f97a13582fba677c"
},
"downloads": -1,
"filename": "markup_parser-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "69c2326df87535dab38449d54154a8a3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6.0",
"size": 6247,
"upload_time": "2024-06-02T09:48:05",
"upload_time_iso_8601": "2024-06-02T09:48:05.663143Z",
"url": "https://files.pythonhosted.org/packages/b6/4b/e66b2d6efc8127ae6ab7c9d17b7916e5f5149ce5ae0b130c39848debdda2/markup_parser-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-02 09:48:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bigpe",
"github_project": "markup-parser",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "markup-parser"
}