phantombrowser


Namephantombrowser JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/guangrei/PhantomBrowser
SummaryTyped Python wrapper for Phantomjs Cloud API
upload_time2024-10-17 05:04:30
maintainerNone
docs_urlNone
authorguangrei
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

PhantomBrowser is typed Python wrapper for [phantomjscloud.com](https://phantomjscloud.com) api with optimize magic rendering and support asynchronous.

## Installation

```
pip install phantombrowser
```

## Example

render html:

```python
from PhantomBrowser import Browser


browser = Browser()
response = browser.get("https://example.com")
print(response.text)
browser.close()
```

render plain text:
```python
from PhantomBrowser import Browser


browser = Browser()
response = browser.get("https://example.com", render="plainText")
print(response.text)
browser.close()
```

render image:
```python
from PhantomBrowser import Browser


browser = Browser()
response = browser.get("https://example.com", render="png")
browser.saveAs("example.png", response.content)
browser.close()
```

render PDF:
```python
from PhantomBrowser import Browser


browser = Browser()
response = browser.get("https://example.com", render="pdf")
browser.saveAs("example.pdf", response.content)
browser.close()
```

the other method like `browser.post()`, `browser.put()`, `browser.patch()`, `browser.option()` and `browser.delete()` also supported.

You can also use the API key by setting the environment variable `PHANTOMJSCLOUD.COM_APIKEY` or directly in the class
```python
from PhantomBrowser import Browser


browser = Browser("Your API Key")
```

## Asynchronous Example

```python
from PhantomBrowser import AsyncBrowser
import asyncio


async def main():
    browser = AsyncBrowser()
    response = await browser.get("https://example.com")
    print(await response.text())
    await browser.close()

if __name__ == '__main__':
    asyncio.run(main())
```

## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/guangrei/PhantomBrowser",
    "name": "phantombrowser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "guangrei",
    "author_email": "myawn@pm.me",
    "download_url": "https://files.pythonhosted.org/packages/56/fe/ddc93cc99adc70d06644084fda89af504ecf89dc69ad8dc1f9afa7f414ee/phantombrowser-0.0.1.tar.gz",
    "platform": "any",
    "description": "[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nPhantomBrowser is typed Python wrapper for [phantomjscloud.com](https://phantomjscloud.com) api with optimize magic rendering and support asynchronous.\n\n## Installation\n\n```\npip install phantombrowser\n```\n\n## Example\n\nrender html:\n\n```python\nfrom PhantomBrowser import Browser\n\n\nbrowser = Browser()\nresponse = browser.get(\"https://example.com\")\nprint(response.text)\nbrowser.close()\n```\n\nrender plain text:\n```python\nfrom PhantomBrowser import Browser\n\n\nbrowser = Browser()\nresponse = browser.get(\"https://example.com\", render=\"plainText\")\nprint(response.text)\nbrowser.close()\n```\n\nrender image:\n```python\nfrom PhantomBrowser import Browser\n\n\nbrowser = Browser()\nresponse = browser.get(\"https://example.com\", render=\"png\")\nbrowser.saveAs(\"example.png\", response.content)\nbrowser.close()\n```\n\nrender PDF:\n```python\nfrom PhantomBrowser import Browser\n\n\nbrowser = Browser()\nresponse = browser.get(\"https://example.com\", render=\"pdf\")\nbrowser.saveAs(\"example.pdf\", response.content)\nbrowser.close()\n```\n\nthe other method like `browser.post()`, `browser.put()`, `browser.patch()`, `browser.option()` and `browser.delete()` also supported.\n\nYou can also use the API key by setting the environment variable `PHANTOMJSCLOUD.COM_APIKEY` or directly in the class\n```python\nfrom PhantomBrowser import Browser\n\n\nbrowser = Browser(\"Your API Key\")\n```\n\n## Asynchronous Example\n\n```python\nfrom PhantomBrowser import AsyncBrowser\nimport asyncio\n\n\nasync def main():\n    browser = AsyncBrowser()\n    response = await browser.get(\"https://example.com\")\n    print(await response.text())\n    await browser.close()\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Typed Python wrapper for Phantomjs Cloud API",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/guangrei/PhantomBrowser"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28e8d238d3ccea2791ce8cf9ee720a61eb9d3eaaaeea2fc53738dc470ef6a9e7",
                "md5": "66cf5a51b59f23acf1ed80cb499c13a3",
                "sha256": "15a7b9ef500b91513deade9a15b29bcb62b51c41a5bc88b20b22e7c1da020356"
            },
            "downloads": -1,
            "filename": "phantombrowser-0.0.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "66cf5a51b59f23acf1ed80cb499c13a3",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5261,
            "upload_time": "2024-10-17T05:04:29",
            "upload_time_iso_8601": "2024-10-17T05:04:29.110708Z",
            "url": "https://files.pythonhosted.org/packages/28/e8/d238d3ccea2791ce8cf9ee720a61eb9d3eaaaeea2fc53738dc470ef6a9e7/phantombrowser-0.0.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56feddc93cc99adc70d06644084fda89af504ecf89dc69ad8dc1f9afa7f414ee",
                "md5": "36197cbb73fe15a249dd66ddcccc6f32",
                "sha256": "cb9f64d0de67412886a45ebfa2963714fd61aa2882c41df50e56d8a282d79cc9"
            },
            "downloads": -1,
            "filename": "phantombrowser-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "36197cbb73fe15a249dd66ddcccc6f32",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3653,
            "upload_time": "2024-10-17T05:04:30",
            "upload_time_iso_8601": "2024-10-17T05:04:30.616160Z",
            "url": "https://files.pythonhosted.org/packages/56/fe/ddc93cc99adc70d06644084fda89af504ecf89dc69ad8dc1f9afa7f414ee/phantombrowser-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 05:04:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "guangrei",
    "github_project": "PhantomBrowser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "phantombrowser"
}
        
Elapsed time: 0.32549s