Skip to main content

Async-compatible Python module for retrieving WHOIS information for domains.

Project description

Async-compatible Python module for retrieving WHOIS information of domains. Based on richardpenman/pywhois

Installation

pip install asyncwhois

Examples

asyncio

import asyncio
import time

import asyncwhois


async def main():
    urls = [
        'https://www.google.co.uk',
        'en.wikipedia.org/wiki/Pi',
        'https://www.urbandictionary.com/define.php?term=async',
        'twitch.tv',
        'reuters.com',
        'https://www.pcpartpicker.com',
        'https://packaging.python.org/',
        'imgur.com'
    ]
    tasks = []
    for url in urls:
        awaitable = asyncwhois.lookup(url)
        tasks.append(awaitable)

    await asyncio.gather(*tasks)


if __name__ == '__main__':
    start = time.time()
    asyncio.run(main())
    print(f'Done! [{round(time.time() - start, 4)}] seconds.')

aiohttp

from aiohttp import web
import asyncwhois


async def whois(request):
    domain = request.match_info.get('domain', 'google.com')
    result = await asyncwhois.lookup(domain)
    return web.Response(text=f'WhoIs parsed:\n{result}')


app = web.Application()
app.add_routes([web.get('/whois/{domain}', whois)])
web.run_app(app)

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

asyncwhois-0.1.2.tar.gz (88.6 kB view hashes)

Uploaded Source

Built Distribution

asyncwhois-0.1.2-py3-none-any.whl (90.2 kB view hashes)

Uploaded Python 3

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