infer the url protocol
This commit is contained in:
+8
-3
@@ -12,10 +12,15 @@ def bypass_paywall(url):
|
|||||||
"""
|
"""
|
||||||
Bypass paywall for a given url
|
Bypass paywall for a given url
|
||||||
"""
|
"""
|
||||||
response = requests.get(url, headers=googlebot_headers)
|
if url.startswith("http"):
|
||||||
response.encoding = response.apparent_encoding
|
response = requests.get(url, headers=googlebot_headers)
|
||||||
return response.text
|
response.encoding = response.apparent_encoding
|
||||||
|
return response.text
|
||||||
|
|
||||||
|
try:
|
||||||
|
return bypass_paywall("https://" + url)
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return bypass_paywall("http://" + url)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def main_page():
|
def main_page():
|
||||||
|
|||||||
Reference in New Issue
Block a user