beautifulspoon


Namebeautifulspoon JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/gzttech/beautifulspoon
Summary
upload_time2024-03-03 11:12:39
maintainer
docs_urlNone
authorGongziting Tech Ltd.
requires_python>=3.6.8,<4.0.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # beautifulspoon

The project is a command line tool build upon [beautifulsoup](https://beautiful-soup-4.readthedocs.io/), or say this is a oneliner's tool for dealing with html files. With beautifulspoon, you can easily modify html files in the shell or within the scripts.

## Install

```
pip install beautifulspoon
```

## Usage

Let's prepare a test.html as below:

```
<html>
 <head>
  <title>
   Hello World
  </title>
 </head>
 <body>
  <div class="container" id="root">
   <a href="https://www.google.com">
    Google
   </a>
  </div>
 </body>
</html>
```

We can explore the functions of beautifulspoon as follow.

- Get the first HTML element matched selectors in `--select`.
```
bspoon test.html --select '#root a'
```

- Get all the HTML element matched selectors in `--select`.
```
bspoon test.html --select '#root a' --all
```

- `--set_name`, change the name of the selected tag.
```
$ bspoon debug/test.html --select a --set_name button|bspoon --select button
<button href="https://www.google.com">
 Google
</button>
```

- `--set_attr`, set attributes for the seleted tag.
```
$ bspoon test.html --select a --set_attr class link|bspoon --select a
<a class="link" href="https://www.google.com">
 Google
</a>
```

- `--append`, append a node(HTML) inside the selected node.
```
$ bspoon test.html --select a --append '<b>Home</b>'|bspoon --select a
<a href="https://www.google.com">
 Google
 <b>
  Home
 </b>
</a>
```

- `--extend`, extend the string(text) of the selected node. Adding `--smooth` may help _smooth_ the extended content. 
```
$ bspoon test.html --select a --extend ' It' --smooth|bspoon --select a
<a href="https://www.google.com">
 Google
    It
</a>

$ bspoon test.html --select a --extend ' It' --smooth|bspoon --select a
<a href="https://www.google.com">
 Google It
</a>
```

- `--insert`, insert a node(HTML) at the POS position inside the selected node. Arguments `--insert_before` and `--insert_after` are the same with `--insert`, with insert position specified at the first and the last slots.
```
$ bspoon test.html --select div --insert 0 '<br/>'| bspoon --select div
<div class="container" id="root">
 <br/>
 <a href="https://www.google.com">
  Google
 </a>
</div>
```

- `--insert_before`(`--ib`), insert a node(HTML) before the selected node.
```
$ bspoon test.html --select a --insert_before '<br/>'|bspoon --select div
<div class="container" id="root">
 <br/>
 <a href="https://www.google.com">
  Google
 </a>
</div>
```
 
- `--insert_after`(`--ia`), insert a node(HTML) next to the position of the selected node.
```
$ bspoon test.html --select a --ia '<br/>'|bspoon --select div
<div class="container" id="root">
 <a href="https://www.google.com">
  Google
 </a>
 <br/>
</div>
```

- `--clear`, clear the inner content of the seleted node.
```
$ bspoon test.html --select div --clear| bspoon --select div
<div class="container" id="root">
</div>
```

- `--decompose`, remove the node along with its inner content of the seleted node.
```
$ bspoon test.html --select div --decompose|bspoon --select body
<body>
</body>
```

- `--replace_with`, replace the seleted node with HTML.
```
$ bspoon test.html --select a --replace_with '<br/>'| bspoon --select div
<div class="container" id="root">
 <br/>
</div>
```

- `--comment`, Comment the selected node.
```
$ bspoon test.html --select a --comment|bspoon --select div
<div class="container" id="root">
 <!-- <a href="https://www.google.com">Google</a> -->
</div>
```

- `--wrap`, wrap the seleted node with tag provided(HTML).
```
$ bspoon test.html --select a --wrap '<p></p>'
| bspoon --select p
<p>
 <a href="https://www.google.com">
  Google
 </a>
</p>
```

- `--unwrap`, unwrap the selected node.
```
$ bspoon test.html --select a --unwrap|bspoon --select div
<div class="container" id="root">
 Google
</div>
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gzttech/beautifulspoon",
    "name": "beautifulspoon",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.8,<4.0.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Gongziting Tech Ltd.",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/dc/69/03bfc49cdcf6589230bd29042677fff01b1270f5549f79af48dcddb563e0/beautifulspoon-0.0.4.tar.gz",
    "platform": null,
    "description": "# beautifulspoon\n\nThe project is a command line tool build upon [beautifulsoup](https://beautiful-soup-4.readthedocs.io/), or say this is a oneliner's tool for dealing with html files. With beautifulspoon, you can easily modify html files in the shell or within the scripts.\n\n## Install\n\n```\npip install beautifulspoon\n```\n\n## Usage\n\nLet's prepare a test.html as below:\n\n```\n<html>\n <head>\n  <title>\n   Hello World\n  </title>\n </head>\n <body>\n  <div class=\"container\" id=\"root\">\n   <a href=\"https://www.google.com\">\n    Google\n   </a>\n  </div>\n </body>\n</html>\n```\n\nWe can explore the functions of beautifulspoon as follow.\n\n- Get the first HTML element matched selectors in `--select`.\n```\nbspoon test.html --select '#root a'\n```\n\n- Get all the HTML element matched selectors in `--select`.\n```\nbspoon test.html --select '#root a' --all\n```\n\n- `--set_name`, change the name of the selected tag.\n```\n$ bspoon debug/test.html --select a --set_name button|bspoon --select button\n<button href=\"https://www.google.com\">\n Google\n</button>\n```\n\n- `--set_attr`, set attributes for the seleted tag.\n```\n$ bspoon test.html --select a --set_attr class link|bspoon --select a\n<a class=\"link\" href=\"https://www.google.com\">\n Google\n</a>\n```\n\n- `--append`, append a node(HTML) inside the selected node.\n```\n$ bspoon test.html --select a --append '<b>Home</b>'|bspoon --select a\n<a href=\"https://www.google.com\">\n Google\n <b>\n  Home\n </b>\n</a>\n```\n\n- `--extend`, extend the string(text) of the selected node. Adding `--smooth` may help _smooth_ the extended content. \n```\n$ bspoon test.html --select a --extend ' It' --smooth|bspoon --select a\n<a href=\"https://www.google.com\">\n Google\n    It\n</a>\n\n$ bspoon test.html --select a --extend ' It' --smooth|bspoon --select a\n<a href=\"https://www.google.com\">\n Google It\n</a>\n```\n\n- `--insert`, insert a node(HTML) at the POS position inside the selected node. Arguments `--insert_before` and `--insert_after` are the same with `--insert`, with insert position specified at the first and the last slots.\n```\n$ bspoon test.html --select div --insert 0 '<br/>'| bspoon --select div\n<div class=\"container\" id=\"root\">\n <br/>\n <a href=\"https://www.google.com\">\n  Google\n </a>\n</div>\n```\n\n- `--insert_before`(`--ib`), insert a node(HTML) before the selected node.\n```\n$ bspoon test.html --select a --insert_before '<br/>'|bspoon --select div\n<div class=\"container\" id=\"root\">\n <br/>\n <a href=\"https://www.google.com\">\n  Google\n </a>\n</div>\n```\n \n- `--insert_after`(`--ia`), insert a node(HTML) next to the position of the selected node.\n```\n$ bspoon test.html --select a --ia '<br/>'|bspoon --select div\n<div class=\"container\" id=\"root\">\n <a href=\"https://www.google.com\">\n  Google\n </a>\n <br/>\n</div>\n```\n\n- `--clear`, clear the inner content of the seleted node.\n```\n$ bspoon test.html --select div --clear| bspoon --select div\n<div class=\"container\" id=\"root\">\n</div>\n```\n\n- `--decompose`, remove the node along with its inner content of the seleted node.\n```\n$ bspoon test.html --select div --decompose|bspoon --select body\n<body>\n</body>\n```\n\n- `--replace_with`, replace the seleted node with HTML.\n```\n$ bspoon test.html --select a --replace_with '<br/>'| bspoon --select div\n<div class=\"container\" id=\"root\">\n <br/>\n</div>\n```\n\n- `--comment`, Comment the selected node.\n```\n$ bspoon test.html --select a --comment|bspoon --select div\n<div class=\"container\" id=\"root\">\n <!-- <a href=\"https://www.google.com\">Google</a> -->\n</div>\n```\n\n- `--wrap`, wrap the seleted node with tag provided(HTML).\n```\n$ bspoon test.html --select a --wrap '<p></p>'\n| bspoon --select p\n<p>\n <a href=\"https://www.google.com\">\n  Google\n </a>\n</p>\n```\n\n- `--unwrap`, unwrap the selected node.\n```\n$ bspoon test.html --select a --unwrap|bspoon --select div\n<div class=\"container\" id=\"root\">\n Google\n</div>\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/gzttech/beautifulspoon"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05b0a2a4b0119b0e7a265025732e7516a30c0487006bd96355ddf9ca8536b153",
                "md5": "93aaba7c319ffe967bf29c9b6073bc15",
                "sha256": "1add578b61f4544293408a1cd61a37ceb2b0074242bbb264e108026cef23b396"
            },
            "downloads": -1,
            "filename": "beautifulspoon-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93aaba7c319ffe967bf29c9b6073bc15",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.8,<4.0.0",
            "size": 4386,
            "upload_time": "2024-03-03T11:12:36",
            "upload_time_iso_8601": "2024-03-03T11:12:36.589102Z",
            "url": "https://files.pythonhosted.org/packages/05/b0/a2a4b0119b0e7a265025732e7516a30c0487006bd96355ddf9ca8536b153/beautifulspoon-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc6903bfc49cdcf6589230bd29042677fff01b1270f5549f79af48dcddb563e0",
                "md5": "590926e0b8255cc35159d6ff97e5e497",
                "sha256": "36b5f6b1242e4ff8423bc60725415bb927a570e4a2a519804140bd2ec9dcc53a"
            },
            "downloads": -1,
            "filename": "beautifulspoon-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "590926e0b8255cc35159d6ff97e5e497",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.8,<4.0.0",
            "size": 3621,
            "upload_time": "2024-03-03T11:12:39",
            "upload_time_iso_8601": "2024-03-03T11:12:39.614723Z",
            "url": "https://files.pythonhosted.org/packages/dc/69/03bfc49cdcf6589230bd29042677fff01b1270f5549f79af48dcddb563e0/beautifulspoon-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-03 11:12:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gzttech",
    "github_project": "beautifulspoon",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "beautifulspoon"
}
        
Elapsed time: 0.24361s