# Path: xpaw/http.py
# class HttpRequest:
# class HttpResponse:
#     def __init__(self, url, method="GET", body=None, params=None, headers=None, proxy=None,
#                  timeout=20, verify_ssl=False, allow_redirects=True, auth=None, proxy_auth=None,
#                  priority=None, dont_filter=False, callback=None, errback=None, meta=None,
#                  render=None):
#     def __str__(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):
#     def to_dict(self):
#     def from_dict(cls, d):
#     def __init__(self, url, status, body=None, headers=None,
#                  request=None, encoding=None):
#     def __str__(self):
#     def encoding(self):
#     def encoding(self, value):
#     def text(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):


import asyncio
import logging
from threading import Thread
from collections import deque
from selenium.webdriver import Chrome, ChromeOptions
from .http import HttpResponse, HttpHeaders
    default_arguments = ['--headless', '--incognito', '--ignore-certificate-errors', '--ignore-ssl-errors',
                         '--disable-gpu', '--no-sandbox']
    default_prefs = {'profile.managed_default_content_settings.images': 2}

    def __init__(self, options=None):
        self.options = {'default': self.make_chrome_options()}
        if options:
            for k, v in options.items():
                self.options[k] = self.make_chrome_options(arguments=v.get('arguments'),
                                                           experimental_options=v.get('experimental_options'))
        self.available_drivers = {}
        for name in self.options.keys():
            self.available_drivers[name] = deque()

    async def fetch(self, request):
        lock = asyncio.Future()
        t = Thread(target=self._run_fetch_thread, args=(asyncio.get_event_loop(), lock, request))
        t.start()
        await lock
        result = lock.result()
        if isinstance(result, Exception):
            raise result
        return result

    def _run_fetch_thread(self, loop, lock, request):
        driver_instance = None
        try:
            driver_instance = self.get_driver_instance(request)
            driver = driver_instance.driver
            driver.get(request.url)

# Path: xpaw/http.py
# class HttpRequest:
# class HttpResponse:
#     def __init__(self, url, method="GET", body=None, params=None, headers=None, proxy=None,
#                  timeout=20, verify_ssl=False, allow_redirects=True, auth=None, proxy_auth=None,
#                  priority=None, dont_filter=False, callback=None, errback=None, meta=None,
#                  render=None):
#     def __str__(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):
#     def to_dict(self):
#     def from_dict(cls, d):
#     def __init__(self, url, status, body=None, headers=None,
#                  request=None, encoding=None):
#     def __str__(self):
#     def encoding(self):
#     def encoding(self, value):
#     def text(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):


# Path: xpaw/renderer.py
import asyncio
import logging
from threading import Thread
from collections import deque
from selenium.webdriver import Chrome, ChromeOptions
from .http import HttpResponse, HttpHeaders

    default_arguments = ['--headless', '--incognito', '--ignore-certificate-errors', '--ignore-ssl-errors',
                         '--disable-gpu', '--no-sandbox']
    default_prefs = {'profile.managed_default_content_settings.images': 2}

    def __init__(self, options=None):
        self.options = {'default': self.make_chrome_options()}
        if options:
            for k, v in options.items():
                self.options[k] = self.make_chrome_options(arguments=v.get('arguments'),
                                                           experimental_options=v.get('experimental_options'))
        self.available_drivers = {}
        for name in self.options.keys():
            self.available_drivers[name] = deque()

    async def fetch(self, request):
        lock = asyncio.Future()
        t = Thread(target=self._run_fetch_thread, args=(asyncio.get_event_loop(), lock, request))
        t.start()
        await lock
        result = lock.result()
        if isinstance(result, Exception):
            raise result
        return result

    def _run_fetch_thread(self, loop, lock, request):
        driver_instance = None
        try:
            driver_instance = self.get_driver_instance(request)
            driver = driver_instance.driver
            driver.get(request.url)

            response = HttpResponse(driver.current_url, 200, body=driver.page_source.encode('utf-8'),