View Single Post
Old 12-16-2023, 04:20 AM   #1
Waseh
Junior Member
Waseh began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2023
Device: Pocketbook inkpad 4
Log in for custom news source

Hello!
I want to ask if someone could help me with a new news source i tried to add. The news outlet has a own RSS feed which i am using, but i also need to log in to get the whole news article text. I tried the code given in the examples, but i think the log in page of the news outlet is somehow different and the code doesnt get it. Can someone please help me with the code?

Here is the news outlet page:
https://www.postimees.ee/
Here is the login page:
https://www.postimees.ee/myaccount?iframe=true
Here is the RSS feed link:
https://www.postimees.ee/rss

And here is the code I put together from the examples:
Code:
from calibre.web.feeds.news import BasicNewsRecipe

class AdvancedUserRecipe1702716630(BasicNewsRecipe):
    title          = 'Postimees'
    oldest_article = 7
    max_articles_per_feed = 100
    auto_cleanup   = True
    needs_subscription = True

    feeds          = [
        ('Postimees', 'https://www.postimees.ee/rss'),
    ]
    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        if self.username is not None and self.password is not None:
            br.open('https://www.postimees.ee/myaccount?iframe=true')
            br.select_form(name='login')
            br['USERID']   = self.username
            br['PASSWORD'] = self.password
            br.submit()
        return br
Here is the error message i get from Calibre:
mechanize._mechanize.FormNotFoundError: no form matching name 'login'

If somene need more infos i would be glad to provide and thank you guys in advance!
Waseh is offline   Reply With Quote