From c147fffe13f1684aff1249ce7f579ea425749836 Mon Sep 17 00:00:00 2001 From: Evan Mackay Date: Mon, 23 Oct 2017 16:46:18 -0700 Subject: [PATCH] Basic scraper to get HTML and CSS of website. --- Python3 Linux/scrape.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Python3 Linux/scrape.py diff --git a/Python3 Linux/scrape.py b/Python3 Linux/scrape.py new file mode 100644 index 0000000..330abfc --- /dev/null +++ b/Python3 Linux/scrape.py @@ -0,0 +1,15 @@ +from urllib import request + +def scrape(url): + req = request.Request( + url=url, + data=None, + headers={ + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36' + } + ) + + f = request.urlopen(req).read().decode('utf-8') + return f + +print(scrape("http://x.com"))