2020-05-04 17:36:00 +02:00
# waybackpy
2020-07-17 21:10:21 +02:00
2020-07-26 06:54:31 +02:00
![contributions welcome ](https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=0059b3&style=flat-square )
2020-07-17 21:10:21 +02:00
[![Build Status ](https://img.shields.io/travis/akamhy/waybackpy.svg?label=Travis%20CI&logo=travis&style=flat-square )](https://travis-ci.org/akamhy/waybackpy)
2020-07-26 06:54:31 +02:00
[![codecov ](https://codecov.io/gh/akamhy/waybackpy/branch/master/graph/badge.svg )](https://codecov.io/gh/akamhy/waybackpy)
2020-11-11 06:14:14 +01:00
[![Downloads ](https://pepy.tech/badge/waybackpy/month )](https://pepy.tech/project/waybackpy)
2020-05-05 15:38:26 +02:00
[![Release ](https://img.shields.io/github/v/release/akamhy/waybackpy.svg )](https://github.com/akamhy/waybackpy/releases)
2020-05-05 06:07:53 +02:00
[![Codacy Badge ](https://api.codacy.com/project/badge/Grade/255459cede9341e39436ec8866d3fb65 )](https://www.codacy.com/manual/akamhy/waybackpy?utm_source=github.com& utm_medium=referral& utm_content=akamhy/waybackpy& utm_campaign=Badge_Grade)
2020-05-06 05:48:02 +02:00
[![Maintainability ](https://api.codeclimate.com/v1/badges/942f13d8177a56c1c906/maintainability )](https://codeclimate.com/github/akamhy/waybackpy/maintainability)
2020-05-07 13:21:08 +02:00
[![CodeFactor ](https://www.codefactor.io/repository/github/akamhy/waybackpy/badge )](https://www.codefactor.io/repository/github/akamhy/waybackpy)
2020-05-05 06:01:43 +02:00
[![made-with-python ](https://img.shields.io/badge/Made%20with-Python-1f425f.svg )](https://www.python.org/)
2020-07-26 06:54:31 +02:00
[![pypi ](https://img.shields.io/pypi/v/waybackpy.svg )](https://pypi.org/project/waybackpy/)
2020-05-07 04:53:31 +02:00
![PyPI - Python Version ](https://img.shields.io/pypi/pyversions/waybackpy?style=flat-square )
2020-05-05 06:01:43 +02:00
[![Maintenance ](https://img.shields.io/badge/Maintained%3F-yes-green.svg )](https://github.com/akamhy/waybackpy/graphs/commit-activity)
2020-07-26 06:54:31 +02:00
![Repo size ](https://img.shields.io/github/repo-size/akamhy/waybackpy.svg?label=Repo%20size&style=flat-square )
[![License: MIT ](https://img.shields.io/badge/License-MIT-yellow.svg )](https://github.com/akamhy/waybackpy/blob/master/LICENSE)
2020-05-05 06:01:43 +02:00
2020-09-08 05:42:48 +02:00
![Wayback Machine ](https://raw.githubusercontent.com/akamhy/waybackpy/master/assets/waybackpy-colored%20284.png )
2020-05-04 17:36:00 +02:00
2020-10-17 08:19:27 +02:00
Waybackpy is a Python package that interfaces with [Internet Archive ](https://en.wikipedia.org/wiki/Internet_Archive )'s [Wayback Machine ](https://en.wikipedia.org/wiki/Wayback_Machine ) API. Archive webpages and retrieve archived webpages easily.
2020-05-04 17:36:00 +02:00
2020-05-05 05:33:16 +02:00
Table of contents
=================
<!-- ts -->
2020-05-05 05:57:02 +02:00
2020-07-17 20:50:58 +02:00
* [Installation ](#installation )
2020-05-05 05:57:02 +02:00
2020-07-17 20:50:17 +02:00
* [Usage ](#usage )
2020-07-26 07:00:54 +02:00
* [As a Python package ](#as-a-python-package )
2020-10-17 13:26:51 +02:00
* [Saving a webpage ](#capturing-aka-saving-an-url-using-save )
2020-10-16 19:07:32 +02:00
* [Retrieving archive ](#retrieving-the-archive-for-an-url-using-archive_url )
2020-10-02 21:46:19 +02:00
* [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 )
2020-10-16 19:07:32 +02:00
* [Retrieving the JSON response of availability API ](#retrieving-the-json-reponse-for-the-avaliblity-api-request )
2020-10-02 21:46:19 +02:00
* [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 )
* [Count total archives for an URL ](#count-total-archives-for-an-url-using-total_archives )
2020-10-02 22:01:28 +02:00
* [List of URLs that Wayback Machine knows and has archived for a domain name ](#list-of-urls-that-wayback-machine-knows-and-has-archived-for-a-domain-name )
2020-10-02 21:46:19 +02:00
2020-10-02 22:01:28 +02:00
* [With the Command-line interface ](#with-the-command-line-interface )
2020-10-17 13:26:51 +02:00
* [Saving webpage ](#save )
2020-10-16 19:07:32 +02:00
* [Archive URL ](#get-archive-url )
* [Oldest archive URL ](#oldest-archive )
* [Newest archive URL ](#newest-archive )
* [JSON response of API ](#get-json-data-of-avaialblity-api )
2020-07-22 18:05:02 +02:00
* [Total archives ](#total-number-of-archives )
2020-10-02 22:01:28 +02:00
* [Archive near specified time ](#archive-near-time )
2020-07-22 18:05:02 +02:00
* [Get the source code ](#get-the-source-code )
2020-10-02 21:46:19 +02:00
* [Fetch all the URLs that the Wayback Machine knows for a domain ](#fetch-all-the-urls-that-the-wayback-machine-knows-for-a-domain )
2020-05-05 05:57:02 +02:00
2020-07-17 20:50:17 +02:00
* [Tests ](#tests )
2020-05-05 05:57:02 +02:00
2020-07-17 20:50:17 +02:00
* [Dependency ](#dependency )
2020-05-05 05:57:02 +02:00
2020-10-02 21:46:19 +02:00
* [Packaging ](#packaging )
2020-07-18 13:00:20 +02:00
* [License ](#license )
2020-05-05 05:57:02 +02:00
2020-05-05 05:33:16 +02:00
<!-- te -->
2020-05-04 17:36:00 +02:00
## Installation
2020-10-02 20:04:06 +02:00
2020-05-04 17:36:00 +02:00
Using [pip ](https://en.wikipedia.org/wiki/Pip_(package_manager )):
2020-10-02 20:04:06 +02:00
2020-07-18 04:46:59 +02:00
```bash
pip install waybackpy
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
or direct from this repository using git.
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
pip install git+https://github.com/akamhy/waybackpy.git
```
2020-05-04 17:36:00 +02:00
## Usage
2020-07-26 07:00:54 +02:00
### As a Python package
2020-07-22 18:05:02 +02:00
2020-07-19 13:09:39 +02:00
#### Capturing aka Saving an url using save()
2020-10-02 20:04:06 +02:00
2020-05-04 17:36:00 +02:00
```python
import waybackpy
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
url = "https://en.wikipedia.org/wiki/Multivariable_calculus"
user_agent = "Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0"
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
waybackpy_url_obj = waybackpy.Url(url, user_agent)
archive = waybackpy_url_obj.save()
print(archive)
2020-07-19 13:09:39 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
2020-10-17 08:19:27 +02:00
https://web.archive.org/web/20201016171808/https://en.wikipedia.org/wiki/Multivariable_calculus
2020-05-04 17:36:00 +02:00
```
2020-10-02 20:04:06 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPySaveExample > < / sub >
2020-05-04 17:36:00 +02:00
2020-10-16 19:07:32 +02:00
#### Retrieving the archive for an URL using archive_url
```python
import waybackpy
2020-10-17 08:19:27 +02:00
url = "https://www.google.com/"
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:40.0) Gecko/20100101 Firefox/40.0"
2020-10-16 19:07:32 +02:00
2020-10-17 08:19:27 +02:00
waybackpy_url_obj = waybackpy.Url(url, user_agent)
archive_url = waybackpy_url_obj.archive_url
2020-10-16 19:07:32 +02:00
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 >
2020-09-08 05:42:48 +02:00
#### Retrieving the oldest archive for an URL using oldest()
2020-10-02 20:04:06 +02:00
2020-05-04 17:36:00 +02:00
```python
import waybackpy
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
url = "https://www.google.com/"
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:40.0) Gecko/20100101 Firefox/40.0"
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
waybackpy_url_obj = waybackpy.Url(url, user_agent)
oldest_archive_url = waybackpy_url_obj.oldest()
2020-07-19 13:09:39 +02:00
print(oldest_archive_url)
2020-05-04 17:36:00 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
http://web.archive.org/web/19981111184551/http://google.com:80/
```
2020-05-05 05:33:16 +02:00
2020-10-02 20:04:06 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyOldestExample > < / sub >
2020-05-04 17:36:00 +02:00
2020-09-08 05:42:48 +02:00
#### Retrieving the newest archive for an URL using newest()
2020-10-02 20:04:06 +02:00
2020-05-04 17:36:00 +02:00
```python
import waybackpy
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
url = "https://www.facebook.com/"
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0"
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
waybackpy_url_obj = waybackpy.Url(url, user_agent)
newest_archive_url = waybackpy_url_obj.newest()
2020-07-19 13:09:39 +02:00
print(newest_archive_url)
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
2020-10-17 08:19:27 +02:00
https://web.archive.org/web/20201016150543/https://www.facebook.com/
2020-05-04 17:36:00 +02:00
```
2020-05-05 05:33:16 +02:00
2020-10-02 20:04:06 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyNewestExample > < / sub >
2020-05-04 17:36:00 +02:00
2020-10-16 19:07:32 +02:00
#### Retrieving the JSON reponse for the avaliblity API request
```python
import waybackpy
2020-10-17 08:19:27 +02:00
url = "https://www.facebook.com/"
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0"
2020-10-16 19:07:32 +02:00
2020-10-17 08:19:27 +02:00
waybackpy_url_obj = waybackpy.Url(url, user_agent)
json_dict = waybackpy_url_obj.JSON
2020-10-16 19:07:32 +02:00
print(json_dict)
```
```javascript
2020-10-17 08:19:27 +02:00
{'url': 'https://www.facebook.com/', 'archived_snapshots': {'closest': {'available': True, 'url': 'http://web.archive.org/web/20201016150543/https://www.facebook.com/', 'timestamp': '20201016150543', 'status': '200'}}}
2020-10-16 19:07:32 +02:00
```
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyJSON > < / sub >
2020-09-08 05:42:48 +02:00
#### Retrieving archive close to a specified year, month, day, hour, and minute using near()
2020-10-02 20:04:06 +02:00
2020-05-04 17:36:00 +02:00
```python
2020-07-19 13:09:39 +02:00
from waybackpy import Url
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"
2020-10-17 08:19:27 +02:00
url = "https://github.com/"
2020-07-19 13:09:39 +02:00
2020-10-17 08:19:27 +02:00
waybackpy_url_obj = Url(url, user_agent)
2020-07-19 13:09:39 +02:00
# Do not pad (don't use zeros in the month, year, day, minute, and hour arguments). e.g. For January, set month = 1 and not month = 01.
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```python
2020-10-17 08:19:27 +02:00
github_archive_near_2010 = waybackpy_url_obj.near(year=2010)
2020-07-19 13:09:39 +02:00
print(github_archive_near_2010)
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
2020-10-17 08:19:27 +02:00
https://web.archive.org/web/20101018053604/http://github.com:80/
2020-07-19 13:09:39 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```python
2020-10-17 08:19:27 +02:00
github_archive_near_2011_may = waybackpy_url_obj.near(year=2011, month=5)
2020-07-19 13:09:39 +02:00
print(github_archive_near_2011_may)
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
2020-10-17 08:19:27 +02:00
https://web.archive.org/web/20110518233639/https://github.com/
2020-05-04 17:36:00 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```python
2020-10-17 08:19:27 +02:00
github_archive_near_2015_january_26 = waybackpy_url_obj.near(year=2015, month=1, day=26)
2020-07-19 13:09:39 +02:00
print(github_archive_near_2015_january_26)
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
2020-10-17 08:19:27 +02:00
https://web.archive.org/web/20150125102636/https://github.com/
2020-07-19 13:09:39 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```python
2020-10-17 08:19:27 +02:00
github_archive_near_2018_4_july_9_2_am = waybackpy_url_obj.near(year=2018, month=7, day=4, hour=9, minute=2)
2020-07-19 13:09:39 +02:00
print(github_archive_near_2018_4_july_9_2_am)
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
https://web.archive.org/web/20180704090245/https://github.com/
```
2020-10-17 08:19:27 +02:00
< sub > The package doesn't support second argument yet. You are encourged to create a PR ;)< / sub >
2020-07-19 13:09:39 +02:00
2020-07-19 18:58:08 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyNearExample > < / sub >
2020-05-04 17:36:00 +02:00
2020-07-18 12:52:09 +02:00
#### Get the content of webpage using get()
2020-10-02 20:04:06 +02:00
2020-05-05 05:33:16 +02:00
```python
2020-07-18 12:52:09 +02:00
import waybackpy
2020-07-19 13:09:39 +02:00
google_url = "https://www.google.com/"
User_Agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"
waybackpy_url_object = waybackpy.Url(google_url, User_Agent)
# If no argument is passed in get(), it gets the source of the Url used to create the object.
current_google_url_source = waybackpy_url_object.get()
print(current_google_url_source)
# The following chunk of code will force a new archive of google.com and get the source of the archived page.
# waybackpy_url_object.save() type is string.
2020-10-17 08:19:27 +02:00
google_newest_archive_source = waybackpy_url_object.get(waybackpy_url_object.save())
2020-07-19 13:09:39 +02:00
print(google_newest_archive_source)
# waybackpy_url_object.oldest() type is str, it's oldest archive of google.com
2020-10-17 08:19:27 +02:00
google_oldest_archive_source = waybackpy_url_object.get(waybackpy_url_object.oldest())
2020-07-19 13:09:39 +02:00
print(google_oldest_archive_source)
2020-05-05 05:33:16 +02:00
```
2020-07-19 13:09:39 +02:00
2020-10-02 20:04:06 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyGetExample # main . py > < / sub >
2020-05-05 05:33:16 +02:00
2020-05-07 15:32:12 +02:00
#### Count total archives for an URL using total_archives()
2020-10-02 20:04:06 +02:00
2020-05-07 11:42:37 +02:00
```python
2020-07-19 13:09:39 +02:00
import waybackpy
URL = "https://en.wikipedia.org/wiki/Python (programming language)"
UA = "Mozilla/5.0 (iPad; CPU OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
2020-10-17 08:19:27 +02:00
waybackpy_url_object = waybackpy.Url(url=URL, user_agent=UA)
archive_count = waybackpy_url_object.total_archives()
2020-05-07 11:42:37 +02:00
2020-07-19 13:09:39 +02:00
print(archive_count) # total_archives() returns an int
```
2020-10-02 20:04:06 +02:00
2020-07-19 13:09:39 +02:00
```bash
2020-10-17 08:19:27 +02:00
2516
2020-07-19 13:09:39 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-19 18:58:08 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyTotalArchivesExample > < / sub >
2020-07-18 12:52:09 +02:00
2020-10-17 08:31:49 +02:00
#### List of URLs that Wayback Machine knows and has archived for a domain name
2020-10-02 21:46:19 +02:00
1) If alive=True is set, waybackpy will check all URLs to identify the alive URLs. Don't use with popular websites like google or it would take too long.
2) To include URLs from subdomain set sundomain=True
```python
import waybackpy
URL = "akamhy.github.io"
UA = "Mozilla/5.0 (iPad; CPU OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
2020-10-17 08:19:27 +02:00
waybackpy_url_object = waybackpy.Url(url=URL, user_agent=UA)
known_urls = waybackpy_url_object.known_urls(alive=True, subdomain=False) # alive and subdomain are optional.
2020-10-02 21:46:19 +02:00
print(known_urls) # known_urls() returns list of URLs
```
```bash
['http://akamhy.github.io',
'https://akamhy.github.io/waybackpy/',
'https://akamhy.github.io/waybackpy/assets/css/style.css?v=a418a4e4641a1dbaad8f3bfbf293fad21a75ff11',
'https://akamhy.github.io/waybackpy/assets/css/style.css?v=f881705d00bf47b5bf0c58808efe29eecba2226c']
```
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyKnownURLsToWayBackMachineExample # main . py > < / sub >
2020-07-26 07:00:54 +02:00
### With the Command-line interface
2020-07-22 18:05:02 +02:00
#### Save
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
$ waybackpy --url "https://en.wikipedia.org/wiki/Social_media" --user_agent "my-unique-user-agent" --save
https://web.archive.org/web/20200719062108/https://en.wikipedia.org/wiki/Social_media
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyBashSave > < / sub >
2020-10-16 19:07:32 +02:00
#### 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 >
2020-07-22 18:05:02 +02:00
#### Oldest archive
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
$ waybackpy --url "https://en.wikipedia.org/wiki/SpaceX" --user_agent "my-unique-user-agent" --oldest
https://web.archive.org/web/20040803000845/http://en.wikipedia.org:80/wiki/SpaceX
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyBashOldest > < / sub >
#### Newest archive
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
$ waybackpy --url "https://en.wikipedia.org/wiki/YouTube" --user_agent "my-unique-user-agent" --newest
https://web.archive.org/web/20200606044708/https://en.wikipedia.org/wiki/YouTube
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyBashNewest > < / sub >
2020-10-16 19:07:32 +02:00
#### Get JSON data of avaialblity API
```bash
2020-10-17 08:31:49 +02:00
waybackpy --url "https://en.wikipedia.org/wiki/SpaceX" --user_agent "my-unique-user-agent" --json
2020-10-16 19:07:32 +02:00
```
```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 >
2020-07-22 18:05:02 +02:00
#### Total number of archives
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
$ waybackpy --url "https://en.wikipedia.org/wiki/Linux_kernel" --user_agent "my-unique-user-agent" --total
853
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyBashTotal > < / sub >
#### Archive near time
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
$ waybackpy --url facebook.com --user_agent "my-unique-user-agent" --near --year 2012 --month 5 --day 12
https://web.archive.org/web/20120512142515/https://www.facebook.com/
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyBashNear > < / sub >
#### Get the source code
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
```bash
2020-10-02 20:04:06 +02:00
waybackpy --url google.com --user_agent "my-unique-user-agent" --get url # Prints the source code of the url
waybackpy --url google.com --user_agent "my-unique-user-agent" --get oldest # Prints the source code of the oldest archive
waybackpy --url google.com --user_agent "my-unique-user-agent" --get newest # Prints the source code of the newest archive
waybackpy --url google.com --user_agent "my-unique-user-agent" --get save # Save a new archive on wayback machine then print the source code of this archive.
2020-07-22 18:05:02 +02:00
```
2020-10-02 20:04:06 +02:00
2020-07-22 18:05:02 +02:00
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackPyBashGet > < / sub >
2020-10-17 08:31:49 +02:00
#### Fetch all the URLs that the Wayback Machine knows for a domain
2020-10-02 21:46:19 +02:00
1) You can add the '--alive' flag to only fetch alive links.
2) You can add the '--subdomain' flag to add subdomains.
3) '--alive' and '--subdomain' flags can be used simultaneously.
4) All links will be saved in a file, and the file will be created in the current working directory.
```bash
pip install waybackpy
# Ignore the above installation line.
2020-10-17 08:31:49 +02:00
waybackpy --url akamhy.github.io --user_agent "my-user-agent" --known_urls
2020-10-02 21:46:19 +02:00
# Prints all known URLs under akamhy.github.io
2020-10-17 08:31:49 +02:00
waybackpy --url akamhy.github.io --user_agent "my-user-agent" --known_urls --alive
2020-10-02 21:46:19 +02:00
# Prints all known URLs under akamhy.github.io which are still working and not dead links.
2020-10-17 08:31:49 +02:00
waybackpy --url akamhy.github.io --user_agent "my-user-agent" --known_urls --subdomain
2020-10-02 21:46:19 +02:00
# Prints all known URLs under akamhy.github.io inclusing subdomain
2020-10-17 08:31:49 +02:00
waybackpy --url akamhy.github.io --user_agent "my-user-agent" --known_urls --subdomain --alive
2020-10-02 21:46:19 +02:00
# Prints all known URLs under akamhy.github.io including subdomain which are not dead links and still alive.
```
< sub > Try this out in your browser @ < https: / / repl . it / @ akamhy / WaybackpyKnownUrlsFromWaybackMachine # main . sh > < / sub >
2020-05-05 14:17:00 +02:00
## Tests
2020-10-17 08:31:49 +02:00
2020-10-02 20:04:06 +02:00
[Here ](https://github.com/akamhy/waybackpy/tree/master/tests )
2020-07-18 12:52:09 +02:00
2020-10-16 19:07:32 +02:00
To run tests locally:
2020-10-17 08:31:49 +02:00
2020-10-16 19:07:32 +02:00
```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
```
2020-05-05 05:33:16 +02:00
## Dependency
2020-10-02 20:04:06 +02:00
2020-10-16 19:07:32 +02:00
None, just pre-installed [python standard libraries ](https://docs.python.org/3/library/ ).
2020-05-04 17:36:00 +02:00
2020-10-02 18:40:30 +02:00
## Packaging
1. Increment version.
2. Build package ``python setup.py sdist bdist_wheel``.
3. Sign & upload the package ``twine upload -s dist/*``.
2020-05-04 17:36:00 +02:00
## License
2020-10-02 20:04:06 +02:00
2020-10-02 18:40:30 +02:00
Released under the MIT License. See
[license ](https://github.com/akamhy/waybackpy/blob/master/LICENSE ) for details.