Created
March 23, 2019 10:31
-
-
Save wasi0013/be7587b1d23a2f0add4c0240999e6411 to your computer and use it in GitHub Desktop.
HTTP/2 Test using requests_html by parsing keycdn website https://tools.keycdn.com/http2-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests_html | |
def http2_enabled(url): | |
""" | |
scrape https://tools.keycdn.com/http2-test to find http 2/0 support of the given domain url | |
""" | |
url = url.replace("https://", "").replace("http://", "") | |
session = requests_html.HTMLSession() | |
response = session.get("https://tools.keycdn.com/http2-test") | |
script = """ | |
() => { | |
var value = "" | |
if(jQuery.isReady) { | |
$("#public").prop('checked', false); | |
$("#url").val("%s") | |
value = $.post( "http2-query.php", $('#http2Form').serialize()).done(function( data ) {value = data}) | |
} | |
return value; | |
} | |
"""%url | |
result = response.html.render(script=script) | |
# check if the source code contains alert-success class in the bootstrap modal | |
return True if "alert-success" in result else False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment