Fix Nitter blocking RSS fetch by adding User-Agent

This commit is contained in:
esef committed 2026-06-22 23:05:35 +03:00
1 parent 10bf63f993
commit 764d7ab31f
2 files changed
+8 -2

No files matched your search

+2 -1
View File
@@ -19,7 +19,8 @@ class General(commands.Cog):
return await ctx.reply('rss url not configured.')
try:
async with aiohttp.ClientSession() as session:
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
async with aiohttp.ClientSession(headers=headers) as session:
async with session.get(rss_url) as resp:
text = await resp.text()
+6 -1
View File
@@ -42,7 +42,12 @@ class TwitterRSSForwarder:
f.write(self.last_guid or '')
async def _poll(self):
feed = feedparser.parse(self.rss_url)
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
async with aiohttp.ClientSession(headers=headers) as session:
async with session.get(self.rss_url) as resp:
text = await resp.text()
feed = feedparser.parse(text)
if feed.bozo and not feed.entries:
print(f'twitter rss feed error: {feed.bozo_exception}')