Created
February 2, 2022 06:39
-
-
Save harendra21/911909352b424aa8028ad65a04d82f9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import requests | |
status_dict = {"Website": "Status"} | |
def main(): | |
with open("websites.txt", "r") as fr: | |
for line in fr: | |
website = line.strip() | |
status = requests.get(website).status_code | |
status_dict[website] = "working" if status == 200 \ | |
else "not working" | |
# print(status_dict) | |
with open("website_status.csv", "w", newline="") as fw: | |
csv_writers = csv.writer(fw) | |
for key in status_dict.keys(): | |
csv_writers.writerow([key, status_dict[key]]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment