Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
whoisxmlapi committed Dec 16, 2021
0 parents commit 51de9e1
Showing 24 changed files with 1,450 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Build"

on: [push, pull_request]

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 tox
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src tests --count --exit-zero --max-line-length=127 --statistics
- name: Test with tox
env:
API_KEY: ${{ secrets.WHOISXMLAPI_API_KEY }}
run: |
tox -e py
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build
dist
/**/*.egg-info
/**/__pycache__
venv
.env
*.sh
.tox
.idea
5 changes: 5 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Authors
=======

* WHOIS API, Inc - `whoisxmlapi.com <https://whoisxmlapi.com>`_
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Changelog
=========

1.0.0 (2021-12-16)
------------------

* First release
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2021 WHOIS API, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
graft src
graft tests

include AUTHORS.rst
include CHANGELOG.rst
include LICENSE
include README.rst

global-exclude *.py[cod] __pycache__ *.so *.dylib
75 changes: 75 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.. image:: https://img.shields.io/badge/License-MIT-green.svg
:alt: screenshot-py license
:target: https://opensource.org/licenses/MIT

.. image:: https://img.shields.io/pypi/v/screenshot-api.svg
:alt: screenshot-py release
:target: https://pypi.org/project/screenshot-api

.. image:: https://github.com/whois-api-llc/screenshot-py/workflows/Build/badge.svg
:alt: screenshot-py build
:target: https://github.com/whois-api-llc/screenshot-py/actions

========
Overview
========

The client library for
`Screenshot API <https://website-screenshot.whoisxmlapi.com/>`_
in Python language.

The minimum Python version is 3.6.

Installation
============

.. code-block:: shell
pip install screenshot-api
Examples
========

Full API documentation available `here <https://website-screenshot.whoisxmlapi.com/api/documentation/making-requests>`_

Create a new client
-------------------

.. code-block:: python
from screenshotapi import *
client = Client('Your API key')
Capture screenshots
-------------------

.. code-block:: python
client.get(filename='screen.jpg',url='example.com')
Extras
-------------------

.. code-block:: python
cookies = {
'name1': 'value1',
'name2': 'value2'
}
# Pass cookies, emulate mobile device, disable JS, wait for network idle
# event, output API errors in XML, capture PDF screenshot in full page
# mode and get image data in base64.
response = client.get_raw(
url='example.com',
type=ImageFormat.PDF,
mode=Client.SLOW_MODE,
full_page=True,
mobile=True,
output_format=Client.XML_FORMAT,
image_output_format=Client.BASE64_FORMAT,
no_js=True,
cookies=cookies
)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests==2.26.0
75 changes: 75 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import io
import re
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import splitext

from setuptools import find_packages
from setuptools import setup


def read(*names, **kwargs):
return io.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
).read()


version_content = {}
exec(read('src/screenshotapi/version.py'), version_content)

setup(
name='screenshot-api',
version=version_content['VERSION'],
python_requires='>=3.6',
license='MIT',
description='Python client library for Screenshot API.',
long_description='%s\n%s' % (
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
),
author='WHOIS API, Inc',
author_email='[email protected]',
url='https://github.com/whois-api-llc/screenshot-py',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Utilities',
],
keywords=[
'screenshot',
'api',
'whois',
'whoisxmlapi',
],
install_requires=[
'requests',
],
extras_require={
'dev': [
'tox',
'flake8',
]
}
)
13 changes: 13 additions & 0 deletions src/screenshotapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__all__ = ['ApiAuthError', 'ApiRequester', 'BadRequestError', 'Client',
'EmptyApiKeyError', 'ErrorMessage', 'FileError', 'HttpApiError',
'ImageFormat', 'ParameterError', 'ResponseError',
'ScreenshotApiError']

from .client import Client
from .models.request import ImageFormat
from .models.response import ErrorMessage
from .net.http import ApiRequester

from .exceptions.error import ApiAuthError, BadRequestError, \
EmptyApiKeyError, FileError, HttpApiError, ParameterError, \
ResponseError, ScreenshotApiError
Loading

0 comments on commit 51de9e1

Please sign in to comment.