From 84ef462fe22d339420db562e7d1673807dea7fc4 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sat, 4 Mar 2023 20:04:30 -0600 Subject: fake user agent --- unbiased/sources/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unbiased/sources/base.py b/unbiased/sources/base.py index 68211c5..ea81f25 100644 --- a/unbiased/sources/base.py +++ b/unbiased/sources/base.py @@ -61,7 +61,11 @@ class NewsSource(object): @classmethod def _fetch_content(cls, url): - res = requests.get(url, timeout=3) + # fake a regular browser user agent for sites that sniff + headers = { + 'User-Agent': u'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36' + } + res = requests.get(url, timeout=3, headers=headers) if res.status_code == 200: content = res.text else: -- cgit v1.2.3