prepend your domain and it works

just add yourdomain.tld/ before the url and it will bypass the paywall!
This commit is contained in:
Alfredo Casanova
2023-05-31 19:45:03 -03:00
committed by GitHub
parent 5c6c30b95f
commit a04f2c61cc
+13
View File
@@ -1,5 +1,6 @@
import flask
import requests
from flask import request
app = flask.Flask(__name__)
googlebot_headers = {
@@ -94,6 +95,7 @@ def bypass_paywall(url):
"""
response = requests.get(url, headers=googlebot_headers)
response.encoding = response.apparent_encoding
# response.encoding = 'UTF-8'
return response.text
@@ -107,5 +109,16 @@ def show_article():
link = flask.request.form["link"]
return bypass_paywall(link)
@app.route("/", defaults={"path": ""})
@app.route('/<path:path>', methods=["GET"])
def get_article(path):
full_url = request.url
parts = full_url.split('/',4)
if len(parts) >= 5:
actual_url = 'https://' + parts[4]
return bypass_paywall(actual_url)
else:
return "invalid url", 400
app.run(debug=True)