Skip to content

Instantly share code, notes, and snippets.

@harendra21
Created February 2, 2022 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harendra21/911909352b424aa8028ad65a04d82f9c to your computer and use it in GitHub Desktop.
Save harendra21/911909352b424aa8028ad65a04d82f9c to your computer and use it in GitHub Desktop.
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