py_zap
py_zap is a Python scraper for fetching daily broadcast and cable ratings from tvbythenumbers.zap2it.com.
Installation
To install with pip:
>>> pip install py_zap
Or clone this repository and run:
>>> python setup.py install
Broadcast Ratings
Let’s fetch the final broadcast ratings for October 27, 2016.
If no date parameter is included, it will default to yesterday’s date
>>> from py_zap import Broadcast
>>> ratings = Broadcast('October 27, 2016')
Now we can look at the chart entries:
>>> entry = ratings[0] # Gives the 1st entry >>> entry.show # Get the name of the show 'The Big Bang Theory' >>> entry.viewers # Get the number of viewers (in millions) 14.3 >>> entry.rating # Get the rating (percentage) 3.4
We can also print out the whole chart by:
>>> print(ratings)
>>> Final Broadcast Ratings for Thursday, October 27 2016 |Show |Time |Network|Viewers|Rating |Share | +-------------------------------------------------------------------------+ |The Big Bang Theory | 8 p.m.| CBS| 14.3| 3.4| 13.0| |Grey’s Anatomy | 8 p.m.| ABC| 8.2| 2.2| 8.0| |Superstore | 8 p.m.| NBC| 4.2| 1.3| 5.0| |Rosewood | 8 p.m.| FOX| 3.4| 0.8| 3.0| |Legends of Tomorrow | 8 p.m.| The CW| 1.8| 0.6| 2.0| |The Great Indoors | 8:30 p.m.| CBS| 8.8| 1.9| 7.0| |The Good Place | 8:30 p.m.| NBC| 3.9| 1.2| 4.0| |Mom | 9 p.m.| CBS| 7.0| 1.5| 5.0| |Chicago Med | 9 p.m.| NBC| 7.1| 1.5| 5.0| |Notorious | 9 p.m.| ABC| 3.8| 0.8| 3.0| |Pitch | 9 p.m.| FOX| 2.9| 0.8| 3.0| |Supernatural | 9 p.m.| The CW| 1.7| 0.6| 2.0| |Life in Pieces | 9:30 p.m.| CBS| 6.0| 1.4| 5.0| |Pure Genius | 10 p.m.| CBS| 6.2| 1.0| 4.0| |The Blacklist | 10 p.m.| NBC| 5.5| 1.2| 4.0| |How to Get Away with Murder | 10 p.m.| ABC| 4.1| 1.2| 4.0|
By default, the final broadcast ratings are fetched. To access the fast ratings, which are posted earlier but less accurate, set ‘final’ param to False. If there are no final ratings available, it will redirect to fast access ratings.
>>> ratings = Broadcast('October 27, 2016', final=False)
Cable Ratings
To fetch the cable ratings for October 27, 2016:
>>> from py_zap import Cable
>>> ratings = Cable('October 27, 2016')
Other things you can do
Sort chart results
Broadcast or cable ratings can be sorted based on show, net, time, rating, or viewers
Broadcast ratings only can be sorted on share
>>> ratings = Cable('October 27, 2016').sort('viewers') # Sort cable ratings by viewers
>>> ratings = Broadcast('October 27, 2016').sort('share') # Sort broadcast ratings by share (broadcast only)
Fetch specific shows or networks
Pass a list if you want to fetch more than one
>>> ratings = Broadcast('October 27, 2016', show='Supernatural') # Fetch a specific show
>>> ratings = Broadcast('October 27, 2016', network=['CBS', 'NBC']) # Fetch a specific network
Iterate through multiple weeks
>>> next_week = ratings.get_next_week() # Get next week's date
>>> last_week = ratings.get_last_week() # Get last week's date
Get network averages (broadcast only)
>>> averages = ratings.get_averages() # Get the ratings/viewers averages for broadcast networks
>>> averages['NBC']
{'rating': 1.3, 'viewers': 5.56, 'share': 5.0}
Dependencies
License
This project is under the MIT License.
All content is owned by Tribune Media Company. See zap2it.com’s Terms of Service for more details.
Metadata
Release files for py-zap 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_zap-1.2.2.tar.gz | 12.8 kB | Without provenance | Details for py_zap-1.2.2.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_zap-1.2.2-py3.7.egg | Legacy Egg format | - | - | Details for py_zap-1.2.2-py3.7.egg |
| py_zap-1.2.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for py_zap-1.2.2-py2.py3-none-any.whl |
Total release size: 54.4 kB
Release files / py_zap-1.2.2.tar.gz
| Download URL | py_zap-1.2.2.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f2bbee78bdff4d9c6a1262e187990e4d16aab646ded28554133d4ad09b1111f
|
|
BLAKE2b-256 checksum How to use checksums |
36e7583b8a01b5834684779203558bd5f167152fa69aff6fab636b24066f9554
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Release files / py_zap-1.2.2-py3.7.egg
| Download URL | py_zap-1.2.2-py3.7.egg |
|---|---|
| Size | 27.9 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
1988f9b27807dc5f0b3718d938db4d0e5cfbed45221caecbe0aa3c415d8008cb
|
|
BLAKE2b-256 checksum How to use checksums |
024a83d7223d9f3b57a19856d057b51dff80e5e8b1941831f425bccec6939c16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Release files / py_zap-1.2.2-py2.py3-none-any.whl
| Download URL | py_zap-1.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a1e75c079732f1978ddf0c8f531b35cf90c83069017a2f822a005b13b61729c4
|
|
BLAKE2b-256 checksum How to use checksums |
34c400c4954b83e717408cb27c778937c0072d17830f695e133417f090862dd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Security for py-zap 1.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.