From a7c36270c0068ade249b525179787424e78609c1 Mon Sep 17 00:00:00 2001 From: BhagatHarsh <93080554+BhagatHarsh@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:27:42 +0530 Subject: [PATCH 1/2] Getting HexCodes --- Get Hexcodes From Websites/README.md | 4 ++ .../getColoursFromWeb.py | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Get Hexcodes From Websites/README.md create mode 100644 Get Hexcodes From Websites/getColoursFromWeb.py diff --git a/Get Hexcodes From Websites/README.md b/Get Hexcodes From Websites/README.md new file mode 100644 index 00000000..d680f19d --- /dev/null +++ b/Get Hexcodes From Websites/README.md @@ -0,0 +1,4 @@ +This tools allows you to get a python list formated colors.txt file containing most of the colors(*Hexcodes*) that the website had. + +To use the tool you will need to import bs4 library by doing +*pip install bs4* \ No newline at end of file diff --git a/Get Hexcodes From Websites/getColoursFromWeb.py b/Get Hexcodes From Websites/getColoursFromWeb.py new file mode 100644 index 00000000..235f9ef1 --- /dev/null +++ b/Get Hexcodes From Websites/getColoursFromWeb.py @@ -0,0 +1,54 @@ +# import necessary libraries +from bs4 import BeautifulSoup +import requests + + +# function to extract html document from given url +def getHTMLdocument(url): + + # request for HTML document of given url + response = requests.get(url) + + if(response.status_code == 200): + # return HTML document + return response.text + else: + # return None + raise Exception("Invalid URL or Check your internet connection") + + +# assign required credentials +# assign URL +url_to_scrape = input("Enter the URL to be Scraped: ") + +# create document +html_document = getHTMLdocument(url_to_scrape) + +# create soap object +soup = BeautifulSoup(html_document, 'html.parser') + +def getHash(link): + s = '' + i = 0 + n = len(link) + while(i < n): + if(link[i] == '#'): + s += link[i:i+7] + i += 1 + return s + +# find all the anchor tags with "href" +# attribute starting with "https://" + +l = set() + +for link in soup.find_all('td'): + s = getHash(str(link)) + if s != '': + l.add(s.lower()) +file = open('colors.txt', 'a') +file.write('[') +for i in l: + file.write("'"+i+"',") +file.write(']') +file.close() From 5e1cc5d17c390ef31eec754b3b0c99719234c670 Mon Sep 17 00:00:00 2001 From: BhagatHarsh <93080554+BhagatHarsh@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:30:56 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2d86ba54..5705e874 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,4 @@ Incase you have anything to be followed while executing the python script mentio | OTP Verification | https://github.com/DhanushNehru/Python-Scripts/tree/master/OTP%20%20Verify | An OTP Verification Checker OTPVerification.py | | ROCK-PAPER-SCISSOR | https://github.com/DhanushNehru/Python-Scripts/tree/master/ROCK-PAPER-SCISSOR | A python game Rock Paper Scissor. | | File Encryption Decryption | https://github.com/DhanushNehru/Python-Scripts/tree/master/File%20Encryption%20Decryption | Encrypts and Decrypts files using AES Algorithms for Security purposes. | +| Get Hexcodes From Websites | https://github.com/BhagatHarsh/Python-Scripts/tree/master/Get%20Hexcodes%20From%20Websites | Generates a python list containing Hexcodes from website. |