From 1881b98d962ca4e2907c396bd1258acd175d45cc Mon Sep 17 00:00:00 2001 From: Lionel Dricot Date: Tue, 1 Feb 2022 15:53:07 +0100 Subject: [PATCH] adding our own user-agent else offpunk is considered as a bot by many http servers --- offpunk.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/offpunk.py b/offpunk.py index 8803c8d..b36d049 100755 --- a/offpunk.py +++ b/offpunk.py @@ -399,6 +399,7 @@ class HtmlRenderer(): # the real render_html hearth readable = Document(body) summary = readable.summary() + #summary = body #r_body += "\x1b[1;34m\x1b[4m" + self.get_title() + "\x1b[0m""\n" soup = BeautifulSoup(summary, 'html.parser') rendered_body = "" @@ -1031,7 +1032,9 @@ you'll be able to transparently follow links to Gopherspace!""") def _fetch_http(self,gi): - response = requests.get(gi.url) + header = {} + header["User-Agent"] = "Offpunk browser v%s"%_VERSION + response = requests.get(gi.url,headers=header) mime = response.headers['content-type'] body = response.content if "text/" in mime: