https://github.com/michaelfromyeg/pylink
Automating more stuff at work because I'm lazy. This time it's URL testing. Gets CSV data, tests links, formats response codes in output file.
https://github.com/michaelfromyeg/pylink
python requests testing ubc
Last synced: 3 months ago
JSON representation
Automating more stuff at work because I'm lazy. This time it's URL testing. Gets CSV data, tests links, formats response codes in output file.
- Host: GitHub
- URL: https://github.com/michaelfromyeg/pylink
- Owner: michaelfromyeg
- License: other
- Created: 2020-07-07T19:24:14.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-06T00:32:50.000Z (12 months ago)
- Last Synced: 2025-02-08T12:13:53.481Z (5 months ago)
- Topics: python, requests, testing, ubc
- Language: Python
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pylink
Another Python project to automate stuff I'm too lazy to do by hand. Take a list of URLs, and generate a report of their status (tailored to UBC ECE).
[](https://www.python.org/)
[](https://lbesson.mit-license.org/)
## Requirements
- Python
- Data, in the form a csv fileExample CSV data:
```csv
Website
https://ece.ubc.ca/~fvogt/
https://ece.ubc.ca/~ivanov/
```Virtual environment quickstart (for Windows):
```bash
pip install virtualenv
virtualenv env
source ./env/Scripts/active
pip install -r requirements.txt
pip freeze > requirements.txt
```## Usage
Run `python link.py -i -o `, where 'input file' is the name of a CSV file containing URLs under ece.ubc.ca.
### Example
Here's an example console call:
`cd ./src && python link.py -i two.csv -o test.csv`
And here's an example of the program's output (as a Markdown table):
|Origin|Result |Status|
|------|-----------------------------|------|
|https://ece.ubc.ca/~fvogt/|403 @ https://ece.ubc.ca/~fvogt/|Site is secured; I don't have access|
|https://ece.ubc.ca/~ivanov/|302 @ https://ece.ubc.ca/~ivanov/; and finally 200 @ https://ece.ubc.ca/faculty/andre-ivanov|Site redirects to ece.ubc.ca|
|https://ece.ubc.ca/~dany/|200 @ https://ece.ubc.ca/~dany/|Site is hosted here|
|https://ece.ubc.ca/~faizalk/|200 @ https://ece.ubc.ca/~faizalk/|Site is hosted here|
|https://ece.ubc.ca/~farzadk/|200 @ https://ece.ubc.ca/~farzadk/|Site is hosted here|
|https://ece.ubc.ca/~jamesc/|200 @ https://ece.ubc.ca/~jamesc/|Site is hosted here|
|https://ece.ubc.ca/~lyon/|200 @ https://ece.ubc.ca/~lyon/|Site is hosted here|
|https://ece.ubc.ca/~mkarimib/|200 @ https://ece.ubc.ca/~mkarimib/|Site is hosted here|
|https://ece.ubc.ca/~rfoist/|200 @ https://ece.ubc.ca/~rfoist/|Site is hosted here|As CSV:
```csv
Origin,Result,Status
https://ece.ubc.ca/~fvogt/,403 @ https://ece.ubc.ca/~fvogt/,Site is secured; I don't have access
https://ece.ubc.ca/~ivanov/,302 @ https://ece.ubc.ca/~ivanov/; and finally 200 @ https://ece.ubc.ca/faculty/andre-ivanov,Site redirects to ece.ubc.ca
https://ece.ubc.ca/~dany/,200 @ https://ece.ubc.ca/~dany/,Site is hosted here
https://ece.ubc.ca/~faizalk/,200 @ https://ece.ubc.ca/~faizalk/,Site is hosted here
https://ece.ubc.ca/~farzadk/,200 @ https://ece.ubc.ca/~farzadk/,Site is hosted here
https://ece.ubc.ca/~jamesc/,200 @ https://ece.ubc.ca/~jamesc/,Site is hosted here
https://ece.ubc.ca/~lyon/,200 @ https://ece.ubc.ca/~lyon/,Site is hosted here
https://ece.ubc.ca/~mkarimib/,200 @ https://ece.ubc.ca/~mkarimib/,Site is hosted here
https://ece.ubc.ca/~rfoist/,200 @ https://ece.ubc.ca/~rfoist/,Site is hosted here
```And finally, formatted in Excel:

## Future
Handle status codes better.