Skip to main content

A async selenium package to improve performance

Project description

asyncselenium Package

  1. This is a tools and libraries enabling web browser automation.
  2. it makes selenium to be async, and improve the performance!
  3. the useage is the same to selenium to make it easy to use.

you can simply install or upgrade:

pip install -U asyncselenium

if you already make the remote driver running (use the default port 4444):

.. code-block:: python

import asyncio

from selenium import webdriver
from selenium.webdriver.common.by import By
from asyncselenium.webdriver.remote.async_webdriver import AsyncWebdriver
from asyncselenium.webdriver.support.async_wait import AsyncWebDriverWait
from asyncselenium.webdriver.support import async_expected_conditions as ec

async def test_get():
    chrome_options = webdriver.ChromeOptions()
    browser = await AsyncWebdriver(options=chrome_options)
    wait = AsyncWebDriverWait(browser, 20)
    await browser.get('https://www.baidu.com')
    ele = await wait.until(ec.presence_of_element_located((By.XPATH, '//*[@id="su"]')))
    search = await wait.until(ec.presence_of_element_located((By.XPATH, '//*[@id="kw"]')))
    await search.send_keys('python')
    print(await ele.tag_name)
    await asyncio.sleep(3)
    await browser.quit()

asyncio.run(test_get())

.. code-block:: python

import asyncio
import sys
sys.path.append('.')
from selenium.webdriver.chrome import service
from asyncselenium.webdriver.chrome.async_webdriver import WebDriver

driver_path = ''
async def test_get():
    browser = await WebDriver(driver_path)
    await browser.get('https://www.baidu.com')
    await asyncio.sleep(5)
    await browser.quit()

async def test_multi_browser():
    service = WebDriver.get_service(driver_path)
    browser = await WebDriver(driver_path, service=service)
    await browser.get('https://www.baidu.com')
    browser2 = await WebDriver(driver_path, service=service)
    await browser2.get('https://news.baidu.com')
    await asyncio.sleep(5)
    await browser.quit(stop_service=False)
    await browser2.get('https://www.baidu.com')
    await asyncio.sleep(5)
    await browser2.quit()

asyncio.run(test_multi_browser())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asyncselenium-0.0.2.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

asyncselenium-0.0.2-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file asyncselenium-0.0.2.tar.gz.

File metadata

  • Download URL: asyncselenium-0.0.2.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for asyncselenium-0.0.2.tar.gz
Algorithm Hash digest
SHA256 af37f60fa618e408f6db658002f6276d4810beca31fb8b381e0e729b6c6851b0
MD5 89c717d70c7810ec804762e0602ce135
BLAKE2b-256 066ead5359f256291427dad4cfdaf642e126fa80fece900dbd1a3e2ad304b966

See more details on using hashes here.

File details

Details for the file asyncselenium-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: asyncselenium-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for asyncselenium-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 28ad21280151cff3b7680cbaf0e871a091b271d8e2e7f7d286223d9475b05d0b
MD5 2962d35c0e55311faf5b8907bf29bbe9
BLAKE2b-256 bde7fe9bd569d4efe76736e2bf892065d612a8237ce35aee71180d9315c96c8f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page