Skip to content

Commit 9462f18

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 3997481 + 9b21ef8 commit 9462f18

20 files changed

Lines changed: 218 additions & 51 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Check Website Connectivity
2+
3+
This directory contains a simple tool to check connectivity to a number of web sites.
4+
5+
The input file `websites.txt` should contain web site URLs, one per line.
6+
7+
The output file `website_status.csv` contains a two-column report with
8+
the URL of each checked site and its status.
9+
The script simply checks whether the web server returns a 200 status code.
10+
11+
The output file will be overwritten each time you run the tool.
12+
13+
14+
## Prerequisites
15+
16+
This project uses the third-party library
17+
[requests](https://requests.readthedocs.io/)
18+
as well as the `csv` module from the Python standard library.
19+
20+
21+
## How to run the Script
22+
23+
To run this script, type
24+
25+
```
26+
python check_connectivity.py
27+
```
28+
in the directory where you have checked out these files.
29+
(If you have an IDE which lets you run Python files,
30+
and prefer to use that instead,
31+
make sure you configure it to set the working directory to
32+
the one which contains the input file.)
33+
34+
35+
## Development ideas
36+
37+
The CSV should perhaps contain a date stamp, too.
38+
39+
Perhaps add the `logging` library and optionally print progress information.
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import requests
21
import csv
32

3+
import requests
4+
5+
46
status_dict = {"Website": "Status"}
57

6-
if __name__ == "__main__":
78

9+
def main():
810
with open("websites.txt", "r") as fr:
911
for line in fr:
10-
status = requests.get(line.strip()).status_code
11-
status_dict[line] = "working" if status == 200 else "not working"
12+
website = line.strip()
13+
status = requests.get(website).status_code
14+
status_dict[website] = "working" if status == 200 \
15+
else "not working"
1216

13-
print(status_dict)
17+
# print(status_dict)
1418
with open("website_status.csv", "w", newline="") as fw:
1519
csv_writers = csv.writer(fw)
1620
for key in status_dict.keys():
1721
csv_writers.writerow([key, status_dict[key]])
22+
23+
24+
if __name__ == "__main__":
25+
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
Website,Status
2-
"http://web.hike.com/
3-
",working
4-
"https://github.com/chavarera/python-mini-projects/issues/96
5-
",working
6-
"https://www.youtube.com/
7-
",working
8-
"https://dillinger.io/
9-
",working
2+
http://web.hike.com/,working
3+
https://github.com/chavarera/python-mini-projects/issues/96,working
4+
https://www.youtube.com/,working
5+
https://dillinger.io/,working
106
https://pypi.org/,working
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Convert Numbers To Words
2+
<!--Remove the below lines and add yours -->
3+
Convert a number to the written word form
4+
5+
### Prerequisites
6+
<!--Remove the below lines and add yours -->
7+
None
8+
9+
### How to run the script
10+
<!--Remove the below lines and add yours -->
11+
Execute `python3 converter.py`
12+
13+
## Screenshot/GIF showing the sample use of the script
14+
<!--Remove the below lines and add yours -->
15+
![Screenshot of the converter.py file](Screenshot.png)
16+
17+
## *Author Name*
18+
<!--Remove the below lines and add yours -->
19+
Niraj Shrestha
25.3 KB
Loading

projects/Find_imdb_rating/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
beautifulsoup4==4.9.1
2-
bs4==0.0.1
32
certifi==2020.6.20
43
chardet==3.0.4
54
idna==2.10

projects/Movie Information Scraper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This script obtains movie details by scraping IMDB website.
33

44
### Prerequisites
5-
* bs4
5+
* beautifulsoup4
66
* requests
77
* Run `pip install -r requirements.txt` to install required external modules.
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
bs4==0.0.1
2-
requests==2.23.0
1+
beautifulsoup4
2+
requests==2.23.0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Random word from list
2+
3+
This is a useful program that chooses a random word from a given list.
4+
5+
#### How to run script
6+
``` bash
7+
python Random_word_from_list.py
8+
```
9+
Make sure you have a file in the same directory you wish to choose a random word from.

0 commit comments

Comments
 (0)