From 149c6b4489d34bcfb53bea8e872066386ef823ee Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sun, 3 Mar 2024 22:07:18 +0100 Subject: [PATCH] chg: [rssfind] set coherent `User-Agent` headers --- bin/rssfind.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/rssfind.py b/bin/rssfind.py index c25b6f6..ce03b0b 100644 --- a/bin/rssfind.py +++ b/bin/rssfind.py @@ -14,7 +14,7 @@ def findfeeds(url=None, disable_strict=False): if url is None: return None - raw = requests.get(url).text + raw = requests.get(url, headers=headers).text results = [] discovered_feeds = [] html = bs4(raw, features="lxml") @@ -52,9 +52,12 @@ def findfeeds(url=None, disable_strict=False): version = "0.2" -feedparser.USER_AGENT = ( - "rssfind.py " + version + " +https://github.com/adulau/rss-tools" -) +user_agent = f"rssfind.py {version} +https://github.com/adulau/rss-tools" + +feedparser.USER_AGENT = user_agent + + +headers = {"User-Agent": user_agent} usage = "Find RSS or Atom feeds from an URL\nusage: %prog [options]"