From f1e76d8d41eac6e2cd1b5eebabc2be9cea9a2512 Mon Sep 17 00:00:00 2001 From: Pin Date: Thu, 13 Jan 2022 21:47:44 -0500 Subject: [PATCH] Added README --- README.md | 14 +++++++++++++- main.py | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 17ed712..3bec1f2 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ -# Please use this read me file for the information required to be submitted per the assignment on MyCourses. +# HTTP JavaScript Scraper + +Run the code with the following: + +```bash +python3 main.py https://www.nintendo.com +``` + +Any site that does not serve HTTP/2 content will return a 301 HTTP response code and fail out of the program. +This can be seen by plugging in `https://www.rit.edu` into the input. +It will return a 301 trying to redirect you to HTTP/2 on the same address and port. +No additional dependencies are required. + diff --git a/main.py b/main.py index 9b907e8..066028b 100644 --- a/main.py +++ b/main.py @@ -159,6 +159,12 @@ def conn_type_parse(): return conn_port def check_connection_succ(text): + """ + Exits program if any HTTP responce code other than 200 is met + :param str: full HTTP responce + """ + # If the website is using HTTP/2 and has no HTTP/1.1 options + # you will receive an error here since it returns a 301 code if text.split("\n")[0].find("200") == -1: print("Error on HTTP request") print("HTTP Return Code: %s" % text.split("\n")[0])