From f0f88dc4d6b4df4603df68c7ad002436dc9eddaa Mon Sep 17 00:00:00 2001 From: x p k Date: Wed, 29 Mar 2023 13:59:25 +0800 Subject: [PATCH] NEW: python url checkers --- py/url-check-requests.py | 7 +++++++ py/url-check-selenium.py | 11 +++++++++++ py/url-check-urllib.py | 6 ++++++ py/url-check-urllib3.py | 10 ++++++++++ 4 files changed, 34 insertions(+) create mode 100755 py/url-check-requests.py create mode 100755 py/url-check-selenium.py create mode 100755 py/url-check-urllib.py create mode 100755 py/url-check-urllib3.py diff --git a/py/url-check-requests.py b/py/url-check-requests.py new file mode 100755 index 0000000..1024adc --- /dev/null +++ b/py/url-check-requests.py @@ -0,0 +1,7 @@ +#!/usr/bin/python3 +import requests + +url = "https://stats.oecd.org/" +resp = requests.get(url) + +print(resp.text) diff --git a/py/url-check-selenium.py b/py/url-check-selenium.py new file mode 100755 index 0000000..6a24654 --- /dev/null +++ b/py/url-check-selenium.py @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +from selenium import webdriver + +url = "https://blog.headdesk.me" +options = webdriver.ChromeOptions() +options.add_argument('ignore-certificate-errors') + +driver = webdriver.Chrome(options=options) +driver.get(url) +driver.save_screenshot("site.png") +driver.close() diff --git a/py/url-check-urllib.py b/py/url-check-urllib.py new file mode 100755 index 0000000..241a1b0 --- /dev/null +++ b/py/url-check-urllib.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 +from urllib.request import urlopen +url = "https://stats.oecd.org/" +with urlopen(url) as response: + body = response.read() +print(body) diff --git a/py/url-check-urllib3.py b/py/url-check-urllib3.py new file mode 100755 index 0000000..7b8cdc4 --- /dev/null +++ b/py/url-check-urllib3.py @@ -0,0 +1,10 @@ +#!/usr/bin/python3 +import urllib3 +from urllib3 import Timeout + +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +http = urllib3.PoolManager(cert_reqs='CERT_NONE') +url = "https://stats.oecd.org/" +r = http.request('GET', url, timeout=Timeout(10)) + +print("statusCode: %s" % r.status)