Update README, drop python 2 support

* Drop python 2 support

* updated docs

* added new docs
This commit is contained in:
Akash Mahanty 2020-10-16 22:37:32 +05:30 committed by GitHub
parent 3e9cf23578
commit 0a2f97c034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 8 deletions

View File

@ -28,8 +28,10 @@ Table of contents
* [Usage](#usage) * [Usage](#usage)
* [As a Python package](#as-a-python-package) * [As a Python package](#as-a-python-package)
* [Saving an url](#capturing-aka-saving-an-url-using-save) * [Saving an url](#capturing-aka-saving-an-url-using-save)
* [Retrieving archive](#retrieving-the-archive-for-an-url-using-archive_url)
* [Retrieving the oldest archive](#retrieving-the-oldest-archive-for-an-url-using-oldest) * [Retrieving the oldest archive](#retrieving-the-oldest-archive-for-an-url-using-oldest)
* [Retrieving the recent most/newest archive](#retrieving-the-newest-archive-for-an-url-using-newest) * [Retrieving the recent most/newest archive](#retrieving-the-newest-archive-for-an-url-using-newest)
* [Retrieving the JSON response of availability API](#retrieving-the-json-reponse-for-the-avaliblity-api-request)
* [Retrieving archive close to a specified year, month, day, hour, and minute](#retrieving-archive-close-to-a-specified-year-month-day-hour-and-minute-using-near) * [Retrieving archive close to a specified year, month, day, hour, and minute](#retrieving-archive-close-to-a-specified-year-month-day-hour-and-minute-using-near)
* [Get the content of webpage](#get-the-content-of-webpage-using-get) * [Get the content of webpage](#get-the-content-of-webpage-using-get)
* [Count total archives for an URL](#count-total-archives-for-an-url-using-total_archives) * [Count total archives for an URL](#count-total-archives-for-an-url-using-total_archives)
@ -37,8 +39,10 @@ Table of contents
* [With the Command-line interface](#with-the-command-line-interface) * [With the Command-line interface](#with-the-command-line-interface)
* [Save](#save) * [Save](#save)
* [Oldest archive](#oldest-archive) * [Archive URL](#get-archive-url)
* [Newest archive](#newest-archive) * [Oldest archive URL](#oldest-archive)
* [Newest archive URL](#newest-archive)
* [JSON response of API](#get-json-data-of-avaialblity-api)
* [Total archives](#total-number-of-archives) * [Total archives](#total-number-of-archives)
* [Archive near specified time](#archive-near-time) * [Archive near specified time](#archive-near-time)
* [Get the source code](#get-the-source-code) * [Get the source code](#get-the-source-code)
@ -93,6 +97,26 @@ https://web.archive.org/web/20200504141153/https://github.com/akamhy/waybackpy
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPySaveExample></sub> <sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPySaveExample></sub>
#### Retrieving the archive for an URL using archive_url
```python
import waybackpy
archive_url = waybackpy.Url(
"https://www.google.com/",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:40.0) Gecko/20100101 Firefox/40.0"
).archive_url
print(archive_url)
```
```bash
https://web.archive.org/web/20201016153320/https://www.google.com/
```
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyArchiveUrl></sub>
#### Retrieving the oldest archive for an URL using oldest() #### Retrieving the oldest archive for an URL using oldest()
```python ```python
@ -134,6 +158,26 @@ https://web.archive.org/web/20200714013225/https://www.facebook.com/
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyNewestExample></sub> <sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyNewestExample></sub>
#### Retrieving the JSON reponse for the avaliblity API request
```python
import waybackpy
json_dict = waybackpy.Url(
"https://www.google.com/",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:40.0) Gecko/20100101 Firefox/40.0"
).JSON
print(json_dict)
```
```javascript
{'url': 'https://www.google.com/', 'archived_snapshots': {'closest': {'available': True, 'url': 'http://web.archive.org/web/20201016153320/https://www.google.com/', 'timestamp': '20201016153320', 'status': '200'}}}
```
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyJSON></sub>
#### Retrieving archive close to a specified year, month, day, hour, and minute using near() #### Retrieving archive close to a specified year, month, day, hour, and minute using near()
```python ```python
@ -286,6 +330,15 @@ https://web.archive.org/web/20200719062108/https://en.wikipedia.org/wiki/Social_
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyBashSave></sub> <sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyBashSave></sub>
#### Get archive URL
```bash
$ waybackpy --url "https://en.wikipedia.org/wiki/SpaceX" --user_agent "my-unique-user-agent" --archive_url
https://web.archive.org/web/20201007132458/https://en.wikipedia.org/wiki/SpaceX
```
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyBashArchiveUrl></sub>
#### Oldest archive #### Oldest archive
```bash ```bash
@ -304,6 +357,20 @@ https://web.archive.org/web/20200606044708/https://en.wikipedia.org/wiki/YouTube
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyBashNewest></sub> <sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyBashNewest></sub>
#### Get JSON data of avaialblity API
```bash
$ waybackpy --url "https://en.wikipedia.org/wiki/SpaceX" --user_agent "my-unique-user-agent" --json
```
```javascript
{'archived_snapshots': {'closest': {'timestamp': '20201007132458', 'status': '200', 'available': True, 'url': 'http://web.archive.org/web/20201007132458/https://en.wikipedia.org/wiki/SpaceX'}}, 'url': 'https://en.wikipedia.org/wiki/SpaceX'}
```
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackPyBashJSON></sub>
#### Total number of archives #### Total number of archives
```bash ```bash
@ -365,12 +432,21 @@ waybackpy --url akamhy.github.io --user_agent "my-user-agent" --known_urls --sub
<sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackpyKnownUrlsFromWaybackMachine#main.sh></sub> <sub>Try this out in your browser @ <https://repl.it/@akamhy/WaybackpyKnownUrlsFromWaybackMachine#main.sh></sub>
## Tests ## Tests
[Here](https://github.com/akamhy/waybackpy/tree/master/tests) [Here](https://github.com/akamhy/waybackpy/tree/master/tests)
To run tests locally:
```bash
pip install -U pytest
pip install codecov
pip install pytest pytest-cov
cd tests
pytest --cov=../waybackpy
python -m codecov #For reporting coverage on Codecov
```
## Dependency ## Dependency
None, just python standard libraries (re, json, urllib, argparse and datetime). Both python 2 and 3 are supported :) None, just pre-installed [python standard libraries](https://docs.python.org/3/library/).
## Packaging ## Packaging

View File

@ -22,7 +22,7 @@ setup(
download_url = 'https://github.com/akamhy/waybackpy/archive/2.1.9.tar.gz', download_url = 'https://github.com/akamhy/waybackpy/archive/2.1.9.tar.gz',
keywords = ['wayback', 'archive', 'archive website', 'wayback machine', 'Internet Archive'], keywords = ['wayback', 'archive', 'archive website', 'wayback machine', 'Internet Archive'],
install_requires=[], install_requires=[],
python_requires= ">=2.7", python_requires= ">=3.2",
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
@ -30,8 +30,6 @@ setup(
'Topic :: Software Development :: Build Tools', 'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',

View File

@ -2,5 +2,5 @@
class WaybackError(Exception): class WaybackError(Exception):
""" """
Raised when API Service error. Raised when Wayback Machine API Service is unreachable/down.
""" """