adspower


Nameadspower JSON
Version 2.0.2 PyPI version JSON
download
home_pagehttps://github.com/blnkoff/adspower
SummaryThe package for interacting with API of anti-detect browser AdsPower.
upload_time2024-06-10 22:29:17
maintainerNone
docs_urlNone
authorAlexey
requires_python<4.0,>=3.11
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # adspower

[![Croco Logo](https://i.ibb.co/G5Pjt6M/logo.png)](https://t.me/crocofactory)<a href="https://www.adspower.com"><img height="35" src="https://www.adspower.com/dist/logo_global.png"></a>

The package for interacting with API of anti-detect browser [AdsPower](https://www.adspower.com).

- **[Telegram channel](https://t.me/crocofactory)**
- **[Overview](#quick-start)**
- **[Installing](#installing-adspower)**
- **[Bug reports](https://github.com/blnkoff/adspower/issues)**

adspower's source code is made available under the [MIT License](LICENSE)
         
## Features
- Synchronous and asynchronous interaction with the local API
- Interaction with the most popular libraries for browser automation in Python: Selenium and Playwright

## Restrictions
1. During using the package, AdsPower must be opened. 
2. The local API is available only in paid AdsPower subscriptions
3. AdsPower has frequency control for all APIs, max. access frequency: 1 request/second 


## Quick start

*Example of interacting with synchronous API.*

```python
from adspower.sync_api import Group, ProfileAPI
group = Group.create(name='my_group', remark='The best group ever')

profile_api = ProfileAPI.create(group=group)  
print(f'Profile {profile_api.name} was created in group {group.name}')
```

**Use `ProfileAPI` only when** you don't need `Selenium` and `Playwright` interactions.

Library provides ways to interact the most popular libraries for browser automation in Python: `Selenium` and `Playwright`.
To get a browser, you can use `with` statement:

- *Selenium*

```python
from adspower.sync_api.selenium import Profile, Group
my_group = Group.query(name='my_group')[0]
profile = Profile.create(group=my_group, name='my_profile')

with profile as browser:
   browser.get('https://github.com/blnkoff/adspower')
```

- *Playwright*

```python
from adspower.async_api.playwright import Profile, Group

async def main() -> None:
    my_group = (await Group.query(name='my_group'))[0]
    profile = await Profile.create(group=my_group, name='my_profile')
    
    async with profile as browser:
       page = browser.pages[0]
       await page.goto('https://github.com/blnkoff/adspower')
```

Both versions support sync and async API.

Or manually call `get_browser` if you need specify part of behaviour.
```python
from adspower.sync_api.selenium import Profile, Group

my_group = Group.query(name='my_group')[0]
profile = Profile.create(group=my_group, name='my_profile')
browser = profile.get_browser(ip_tab=False, headless=True, disable_password_filling=True)
browser.get('https://github.com/blnkoff/adspower')
profile.quit()
```

Notice that you must not call quitting methods of `Playwright` library or `Selenium` after `profile.quit()`, since 
it calls these methods automatically. An attempt to do so will lead to the error.
           
*Example of setting proxy and fingerprint*

```python
from adspower.sync_api.playwright import Profile, Group
from adspower import ProxyConfig, FingerprintConfig

proxy = ProxyConfig(
    soft='other',
    type='http',
    host='xx.xx.x.xx',
    port=1000,
    user='username',
    password='password'
)

fingerprint = FingerprintConfig(
    ua='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.112 Safari/537.36'
)

group = Group.query(name='my_group')[0]
profile = Profile.create(group=group, proxy_config=proxy, name='my_profile', fingerprint_config=fingerprint)
```

There are extension categories, implemented as `Category` class. At the moment, it can`t be created, but can be retrieved.
You can manually create extension category and used it for profile creation using API.
  
*Example of querying category* 

```python
from adspower.sync_api.playwright import Profile, Category, Group

category = Category.query(name='my_category')[0]
group = Group.query(name='my_group')[0]

profile = Profile.create(group=group, category=category)
```

You can create anonymous profile that is deleted after last statement in context manager.
   
*Example of anonymous profile*
```python
from adspower.async_api.playwright import Profile, Group

async def main() -> None:
    my_group = (await Group.query(name='my_group'))[0]
    profile = await Profile.anonymous(group=my_group)

    async with profile as browser:
        page = browser.pages[0]
        await page.goto('https://www.google.com')
```

Each API entity, such as Profile, Group and Category, pretty formatted, can be compared and converted to dict
     
*Example 1*

```python
from adspower.sync_api.playwright import Category

category = Category.query(name='my_category')[0]
print(category) 
```

```markdown
Category(id=10515; name=my_category)
```
  
*Example 2*

```python
from adspower.sync_api.playwright import Profile, Group

group = Group.query(name='my_group')[0]
profile_created = Profile.create(group=group)

profile_queried = Profile.query(id_=profile_created.id)
print(profile_queried == profile_created)
```

```python
True
```

*Example 3*
```python
from adspower.sync_api.playwright import Category

category = Category.query(name='my_category')[0]
print(category.to_dict())
```

```json
{
    "id": 10515, 
    "name": "my_category", 
    "remark": "category remark"
}
```

# Installing adspower
To install the package from PyPi you can use that:

```sh
pip install adspower
```

You will probably want to use the pacakge with `Selenium` or `Playwright`. You can install it as extra-package:

```sh
pip install adspower[playwright]
```

```sh
pip install adspower[selenium]
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/blnkoff/adspower",
    "name": "adspower",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Alexey",
    "author_email": "axbelenkov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/47/20/f6b6bf1becb91e8879fabbff6cad11e721eb5f82f433264fac7aa82af914/adspower-2.0.2.tar.gz",
    "platform": null,
    "description": "# adspower\n\n[![Croco Logo](https://i.ibb.co/G5Pjt6M/logo.png)](https://t.me/crocofactory)<a href=\"https://www.adspower.com\"><img height=\"35\" src=\"https://www.adspower.com/dist/logo_global.png\"></a>\n\nThe package for interacting with API of anti-detect browser [AdsPower](https://www.adspower.com).\n\n- **[Telegram channel](https://t.me/crocofactory)**\n- **[Overview](#quick-start)**\n- **[Installing](#installing-adspower)**\n- **[Bug reports](https://github.com/blnkoff/adspower/issues)**\n\nadspower's source code is made available under the [MIT License](LICENSE)\n         \n## Features\n- Synchronous and asynchronous interaction with the local API\n- Interaction with the most popular libraries for browser automation in Python: Selenium and Playwright\n\n## Restrictions\n1. During using the package, AdsPower must be opened. \n2. The local API is available only in paid AdsPower subscriptions\n3. AdsPower has frequency control for all APIs, max. access frequency: 1 request/second \n\n\n## Quick start\n\n*Example of interacting with synchronous API.*\n\n```python\nfrom adspower.sync_api import Group, ProfileAPI\ngroup = Group.create(name='my_group', remark='The best group ever')\n\nprofile_api = ProfileAPI.create(group=group)  \nprint(f'Profile {profile_api.name} was created in group {group.name}')\n```\n\n**Use `ProfileAPI` only when** you don't need `Selenium` and `Playwright` interactions.\n\nLibrary provides ways to interact the most popular libraries for browser automation in Python: `Selenium` and `Playwright`.\nTo get a browser, you can use `with` statement:\n\n- *Selenium*\n\n```python\nfrom adspower.sync_api.selenium import Profile, Group\nmy_group = Group.query(name='my_group')[0]\nprofile = Profile.create(group=my_group, name='my_profile')\n\nwith profile as browser:\n   browser.get('https://github.com/blnkoff/adspower')\n```\n\n- *Playwright*\n\n```python\nfrom adspower.async_api.playwright import Profile, Group\n\nasync def main() -> None:\n    my_group = (await Group.query(name='my_group'))[0]\n    profile = await Profile.create(group=my_group, name='my_profile')\n    \n    async with profile as browser:\n       page = browser.pages[0]\n       await page.goto('https://github.com/blnkoff/adspower')\n```\n\nBoth versions support sync and async API.\n\nOr manually call `get_browser` if you need specify part of behaviour.\n```python\nfrom adspower.sync_api.selenium import Profile, Group\n\nmy_group = Group.query(name='my_group')[0]\nprofile = Profile.create(group=my_group, name='my_profile')\nbrowser = profile.get_browser(ip_tab=False, headless=True, disable_password_filling=True)\nbrowser.get('https://github.com/blnkoff/adspower')\nprofile.quit()\n```\n\nNotice that you must not call quitting methods of `Playwright` library or `Selenium` after `profile.quit()`, since \nit calls these methods automatically. An attempt to do so will lead to the error.\n           \n*Example of setting proxy and fingerprint*\n\n```python\nfrom adspower.sync_api.playwright import Profile, Group\nfrom adspower import ProxyConfig, FingerprintConfig\n\nproxy = ProxyConfig(\n    soft='other',\n    type='http',\n    host='xx.xx.x.xx',\n    port=1000,\n    user='username',\n    password='password'\n)\n\nfingerprint = FingerprintConfig(\n    ua='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.112 Safari/537.36'\n)\n\ngroup = Group.query(name='my_group')[0]\nprofile = Profile.create(group=group, proxy_config=proxy, name='my_profile', fingerprint_config=fingerprint)\n```\n\nThere are extension categories, implemented as `Category` class. At the moment, it can`t be created, but can be retrieved.\nYou can manually create extension category and used it for profile creation using API.\n  \n*Example of querying category* \n\n```python\nfrom adspower.sync_api.playwright import Profile, Category, Group\n\ncategory = Category.query(name='my_category')[0]\ngroup = Group.query(name='my_group')[0]\n\nprofile = Profile.create(group=group, category=category)\n```\n\nYou can create anonymous profile that is deleted after last statement in context manager.\n   \n*Example of anonymous profile*\n```python\nfrom adspower.async_api.playwright import Profile, Group\n\nasync def main() -> None:\n    my_group = (await Group.query(name='my_group'))[0]\n    profile = await Profile.anonymous(group=my_group)\n\n    async with profile as browser:\n        page = browser.pages[0]\n        await page.goto('https://www.google.com')\n```\n\nEach API entity, such as Profile, Group and Category, pretty formatted, can be compared and converted to dict\n     \n*Example 1*\n\n```python\nfrom adspower.sync_api.playwright import Category\n\ncategory = Category.query(name='my_category')[0]\nprint(category) \n```\n\n```markdown\nCategory(id=10515; name=my_category)\n```\n  \n*Example 2*\n\n```python\nfrom adspower.sync_api.playwright import Profile, Group\n\ngroup = Group.query(name='my_group')[0]\nprofile_created = Profile.create(group=group)\n\nprofile_queried = Profile.query(id_=profile_created.id)\nprint(profile_queried == profile_created)\n```\n\n```python\nTrue\n```\n\n*Example 3*\n```python\nfrom adspower.sync_api.playwright import Category\n\ncategory = Category.query(name='my_category')[0]\nprint(category.to_dict())\n```\n\n```json\n{\n    \"id\": 10515, \n    \"name\": \"my_category\", \n    \"remark\": \"category remark\"\n}\n```\n\n# Installing adspower\nTo install the package from PyPi you can use that:\n\n```sh\npip install adspower\n```\n\nYou will probably want to use the pacakge with `Selenium` or `Playwright`. You can install it as extra-package:\n\n```sh\npip install adspower[playwright]\n```\n\n```sh\npip install adspower[selenium]\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The package for interacting with API of anti-detect browser AdsPower.",
    "version": "2.0.2",
    "project_urls": {
        "Homepage": "https://github.com/blnkoff/adspower",
        "Repository": "https://github.com/blnkoff/adspower"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf5a1f894a6f5d37bbc71df87631accbbdc75b327b296e0029b9078fc703c073",
                "md5": "9d89ac40acfab09ab6506cdc2910a3b4",
                "sha256": "014167d7f4e82dc26872fe492d6c1b4a059dbb846d2bfcdf710399b5c0976fc9"
            },
            "downloads": -1,
            "filename": "adspower-2.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9d89ac40acfab09ab6506cdc2910a3b4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 36645,
            "upload_time": "2024-06-10T22:29:15",
            "upload_time_iso_8601": "2024-06-10T22:29:15.328841Z",
            "url": "https://files.pythonhosted.org/packages/bf/5a/1f894a6f5d37bbc71df87631accbbdc75b327b296e0029b9078fc703c073/adspower-2.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4720f6b6bf1becb91e8879fabbff6cad11e721eb5f82f433264fac7aa82af914",
                "md5": "99e8a87c5f6bb76136a1a57f451e9937",
                "sha256": "fdb4cc90dd5312f5ed87b8e7a3499dac66d2fd3678bf3466ed38bd0d1be5233d"
            },
            "downloads": -1,
            "filename": "adspower-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "99e8a87c5f6bb76136a1a57f451e9937",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 59858,
            "upload_time": "2024-06-10T22:29:17",
            "upload_time_iso_8601": "2024-06-10T22:29:17.647173Z",
            "url": "https://files.pythonhosted.org/packages/47/20/f6b6bf1becb91e8879fabbff6cad11e721eb5f82f433264fac7aa82af914/adspower-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-10 22:29:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "blnkoff",
    "github_project": "adspower",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "adspower"
}
        
Elapsed time: 0.28359s