Fix Nitter blocking RSS fetch by adding User-Agent
This commit is contained in:
1 parent
10bf63f993
commit
764d7ab31f
2 files changed
+8
-2
No files matched your search
+2
-1
@@ -19,7 +19,8 @@ class General(commands.Cog):
|
|||||||
return await ctx.reply('rss url not configured.')
|
return await ctx.reply('rss url not configured.')
|
||||||
|
|
||||||
try:
|
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:
|
async with session.get(rss_url) as resp:
|
||||||
text = await resp.text()
|
text = await resp.text()
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,12 @@ class TwitterRSSForwarder:
|
|||||||
f.write(self.last_guid or '')
|
f.write(self.last_guid or '')
|
||||||
|
|
||||||
async def _poll(self):
|
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:
|
if feed.bozo and not feed.entries:
|
||||||
print(f'twitter rss feed error: {feed.bozo_exception}')
|
print(f'twitter rss feed error: {feed.bozo_exception}')
|
||||||
|
|||||||
Reference in new issue
Block a user