# webscraping-ai
A client for https://webscraping.ai API. It provides a web scaping automation API with Chrome JS rendering, rotating proxies and builtin HTML parsing.

This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 2.0.2
- Package version: 2.0.2
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://webscraping.ai](https://webscraping.ai)

## Requirements.

Python 2.7 and 3.4+

## Installation & Usage
### pip install

If the python package is hosted on a repository, you can install directly using:

```sh
pip install git+https://github.com/webscraping-ai/webscraping-ai-python.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/webscraping-ai/webscraping-ai-python.git`)

Then import the package:
```python
import webscraping_ai
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

Then import the package:
```python
import webscraping_ai
```

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```python
from __future__ import print_function

import time
import webscraping_ai
from webscraping_ai.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.webscraping.ai
# See configuration.py for a list of all supported configuration parameters.
configuration = webscraping_ai.Configuration(
    host = "https://api.webscraping.ai"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: api_key
configuration = webscraping_ai.Configuration(
    host = "https://api.webscraping.ai",
    api_key = {
        'api_key': 'YOUR_API_KEY'
    }
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api_key'] = 'Bearer'


# Enter a context with an instance of the API client
with webscraping_ai.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = webscraping_ai.HTMLApi(api_client)
    url = 'https://example.com' # str | URL of the target page
headers = {'key': '{\"Cookie\":\"session=some_id\"}'} # dict(str, str) | HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"}) (optional)
timeout = 5000 # int | Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (optional) (default to 5000)
js = True # bool | Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (optional) (default to True)
proxy = 'datacenter' # str | Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (optional) (default to 'datacenter')

    try:
        # Page HTML by URL
        api_response = api_instance.get_html(url, headers=headers, timeout=timeout, js=js, proxy=proxy)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling HTMLApi->get_html: %s\n" % e)
    
```

## Documentation for API Endpoints

All URIs are relative to *https://api.webscraping.ai*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*HTMLApi* | [**get_html**](docs/HTMLApi.md#get_html) | **GET** /html | Page HTML by URL
*HTMLApi* | [**post_html**](docs/HTMLApi.md#post_html) | **POST** /html | Page HTML by URL with POST request to the target page
*SelectedHTMLApi* | [**get_selected**](docs/SelectedHTMLApi.md#get_selected) | **GET** /selected | HTML of a selected page area by URL and CSS selector
*SelectedHTMLApi* | [**get_selected_multiple**](docs/SelectedHTMLApi.md#get_selected_multiple) | **GET** /selected-multiple | HTML of multiple page areas by URL and CSS selectors
*SelectedHTMLApi* | [**post_selected**](docs/SelectedHTMLApi.md#post_selected) | **POST** /selected | HTML of a selected page areas by URL and CSS selector, with POST request to the target page
*SelectedHTMLApi* | [**post_selected_multiple**](docs/SelectedHTMLApi.md#post_selected_multiple) | **POST** /selected-multiple | HTML of multiple page areas by URL and CSS selectors, with POST request to the target page


## Documentation For Models

 - [Error](docs/Error.md)
 - [PageError](docs/PageError.md)


## Documentation For Authorization


## api_key

- **Type**: API key
- **API key parameter name**: api_key
- **Location**: URL query string


## Author

support@webscraping.ai


