Привет, Codeforces!
Я на днях написал скрипт, который публикует все новые посты (и их обновления) с Codeforces в Телеграм-канал -- с форматированием и всем причитающимся.
- @cf_blogs -- английская версия.
- @cf_blogs_ru -- русская версия.
Обновления должны приходить достаточно быстро, меньше чем за 5 минут.
Приятного использования!
Автокомментарий: текст был обновлен пользователем purplesyringa (предыдущая версия, новая версия, сравнить).
Автокомментарий: текст был обновлен пользователем purplesyringa (предыдущая версия, новая версия, сравнить).
Did you literally made it in 5 minutes?
Well, I started it one-two hours ago. I was making a blog and pushing the final version just when I saw that post. Hence I replied so fast.
This is actually very cool, thanks a lot!
How does it work? Can you share the code? As codeforces doesn't have rss/atom feed, it is a really good initiative. Thanks.
It parses 'Recent actions' in the sidebar and parses these posts. Then it checks if these posts are new and posts them to Telegram if so. There are some hacks to make Codeforces formatting look better, the rest is rather simple. I'm not sure if I want to share the code because if many people used it, it would increase load on Codeforces servers. You can DM me if you need it.
You could've used more reliable API for recent actions (see https://codeforces.net/apiHelp/methods#recentActions) instead of parsing HTML which can change at any moment.
I know about the API and I don't like it. First, it has too low limits to be any useful. Second, the API doesn't return blog content so I'd still have to resort to manual parsing.
Codeforces API allows 5 requests per second — should be more than enough to load data once and send to all users.
The API also does return blog content, you have to:
1. Request recentActions
2. Request full versions of BlogEntries by IDs from RecentActions using blogEntry.view
This is fully up to you, of course, it's your bot :)
There are limits other than per second limits. In my experience, even rate limiting API like that doesn't help, you still get 'forbidden' or whatever the error was--I don't remember--if you make many requests per hour.
Also, I'm not just talking about RPS metric. Some APIs that return lists/arrays don't return more than a few hundreds of records.
That API doesn't return post content.
Hi purplesyringa I have a version of the new cf logo in a slightly higher resolution for the profile picture of the channel: link
Thanks! Updated.