Git Product home page Git Product logo

onemillion's Introduction

onemillion

image

image

image

Codacy Badge

Documentation Status

Updates

Determine if a domain is in the Alexa or Cisco top one million domain list.

Documentation is available here: https://onemillion.readthedocs.io . There is a UI/API using this package available here: http://onemillion.hightower.space

Installation

The recommended means of installation is using pip:

pip install onemillion

Alternatively, you can install onemillion as follows:

git clone https://github.com/fhightower/onemillion.git && cd onemillion;
python setup.py install --user;

Usage

When using the default settings, the following steps will be taken when an instance of onemillion is initialized and the domain_in_million function called:

  1. Check to see if the domain lists have been updated today.

2a. If they have been updated today, look for the given domain in the lists and stop.

2b. If the lists have not been updated today, make a HEAD request and check the current etag against the previous etag (stored locally) to see if the lists have been updated.

3a. If the etags are the same (meaning the lists have not been updated), look for the given domain in the lists and stop.

3b. If the etags are different (meaning the lists have been updated), make a request for the lists, unzip them, and save them in the default cache location (~/.onemillion).

  1. Now that the lists are updated, search for the given domain in the lists.

Default Usage ~ Hello World!

Via Python

The default usage of onemillion is as follows:

import onemillion

o = onemillion.OneMillion()
o.domain_in_million("google.com")  # 1
o.domain_in_million("gaagle.com")  # None

Using the method described above, the alexa and cisco top one million domain lists as well as a bit of metadata will be stored in the home directory: ~/.onemillion.

Via Command Line

The default usage of onemillion via command line is as follows:

onemillion google.com

As as when using onemillion in a python script, the alexa and cisco top one million domain lists as well as a bit of metadata will be stored in the home directory: ~/.onemillion.

No Caching

Via Python

If you do not want to cache the domain lists, you can tell onemillion not cache anything by setting cache=False on initialization as demonstrated below:

import onemillion

# do not cache anything
o = onemillion.OneMillion(cache=False)
o.domain_in_million("google.com")  # 1
o.domain_in_million("gaagle.com")  # None

The code described above is fine if you are only making one or two calls or if storage space is a concern, but it is suggested that you cache the lists if feasible so as to limit traffic to the domain lists.

NOTE: currently, the 'No caching' configuration will throw an error. This will be updated and handled when issue #12 is fixed.

Via Command Line

Via command line, same principle as above:

onemillion google.com --no-cache

Custom Cache Location

Via Python

If you are caching the lists but want to cache them somewhere other than your home directory, you can specify a custom cache location by setting the cache_location parameter when initializing onemillion as demonstrated below:

import onemillion

# cache data to a specific path
o = onemillion.OneMillion(cache_location=<YOUR_PATH_HERE>)
o.domain_in_million("google.com")  # 1
o.domain_in_million("gaagle.com")  # None

This will cache the domain lists in the path you provide.

Via Command Line

Via command line, same principle as above:

onemillion google.com --cache_location ~/.cache/onemillion/

or

onemillion google.com -l ~/.cache/onemillion/

No Update

Via Python

If you have already run onemillion and have the domain lists cached, but do not want to keep updating them, you can specify update=False on initialization as demonstrated below:

import onemillion

# do not update cached content
o = onemillion.OneMillion(update=False)
o.domain_in_million("google.com")  # 1
o.domain_in_million("gaagle.com")  # None

Be aware that onemillion will, by default, check to see if it has already updated the domain lists today before making any requests. Thus, onemillion handles updating responsibly and intelligently by default and there are few cases in which this configuration (using update=False) is necessary. Nevertheless... it's there and you are welcome to use it.

Via Command Line

Via command line, same principle as above:

onemillion google.com --no-update

Credits

This package was created with Cookiecutter and the fhightower/python-project-template.

onemillion's People

Contributors

codacy-badger avatar dependabot[bot] avatar fhightower avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hartl3y94

onemillion's Issues

Initial Update

Hi ๐Ÿ‘Š

This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.

Once you have closed this issue, I'll create seperate pull requests for every update as soon as I find one.

That's it for now!

Happy merging! ๐Ÿค–

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.