Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 08-29-2018, 11:53 AM   #1
NSILMike
Guru
NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.
 
Posts: 735
Karma: 35936
Join Date: Apr 2011
Location: Shrewsury, MA
Device: Lenovo Android Tablet
Fortune Magazine fails

File "site-packages\mechanize\_mechanize.py", line 667, in select_form
mechanize._mechanize.FormNotFoundError: no form matching id = 'sign-in-form'
NSILMike is offline   Reply With Quote
Old 08-29-2018, 02:50 PM   #2
lui1
Enthusiast
lui1 began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Dec 2017
Location: Los Angeles, CA
Device: Smart Phone
I think the moved the 'sigin in form' to http://fortune.com/sitemap/. Try this.

Fortune Magazine Recipe
Code:
from calibre.web.feeds.recipes import BasicNewsRecipe


def classes(classes):
    q = frozenset(classes.split(' '))
    return dict(attrs={
        'class': lambda x: x and frozenset(x.split()).intersection(q)})


class Fortune(BasicNewsRecipe):

    title = 'Fortune Magazine'
    __author__ = 'Rick Shang'

    description = 'FORTUNE is a global business magazine that has been revered in its content and credibility since 1930. FORTUNE covers the entire field of business, including specific companies and business trends, prominent business leaders, and new ideas shaping the global marketplace.'  # noqa
    language = 'en'
    category = 'news'
    encoding = 'UTF-8'
    keep_only_tags = [
            dict(name='h1', attrs={'class': lambda x: x and 'headline' in x}),
            classes('lead-media author'),
            dict(id='article-body'),
    ]

    no_javascript = True
    no_stylesheets = True
    needs_subscription = 'optional'

    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        if self.username and self.password:
            br.open('http://fortune.com/sitemap/')
            br.select_form(id='sign-in-form')
            br['username'] = self.username
            br['password'] = self.password
            br.submit()
        return br

    def parse_index(self):
        articles = []

        # Go to the latestissue
        soup = self.index_to_soup('http://fortune.com/section/magazine/')
        articles = []

        for i, article in enumerate(soup.findAll('article', attrs={'class': lambda x: x and 'type-article' in x.split()})):
            div = article.find('div', attrs={'class': lambda x: x and 'article-info' in x.split()})
            a = div.find('a', href=True)
            url = a['href']
            if url.startswith('/'):
                url = 'http://fortune.com' + url
            title = self.tag_to_string(a)
            ai = div.find('div', attrs={'class': lambda x: x and 'article-info-extended' in x.split()})
            desc = ''
            if ai:
                desc = self.tag_to_string(desc)
            self.log('Article:', title, 'at', url)
            articles.append({'title': title, 'url': url, 'description': desc})
        return [('Articles', articles)]
lui1 is offline   Reply With Quote
Advert
Old 08-29-2018, 10:20 PM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
the FM server is having lots of issues, I see lots of intermittent failures, but if the server ever settles down, this should take care of it: https://github.com/kovidgoyal/calibr...b93d2981c4d570
kovidgoyal is offline   Reply With Quote
Old 08-30-2018, 08:59 AM   #4
NSILMike
Guru
NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.NSILMike turned on, tuned in, and dropped out.
 
Posts: 735
Karma: 35936
Join Date: Apr 2011
Location: Shrewsury, MA
Device: Lenovo Android Tablet
Worked fine just now. Did you fix the recipe as per your suggestion? Or should I still make those changes myself?
NSILMike is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortune magazine recipe is broken NSILMike Recipes 1 08-29-2018 11:52 AM
Fortune Magazine recipe is broken NSILMike Recipes 3 08-30-2014 03:24 AM
Fortune Magazine rainrdx Recipes 0 03-25-2013 05:01 PM
Fortune Magazine nitsuj123 Recipes 5 03-15-2013 07:10 AM
Fortune Magazine Suggests iPad Mini to Appear October 17(?) Batman Jr. Apple Devices 9 10-03-2012 11:41 AM


All times are GMT -4. The time now is 01:50 PM.


MobileRead.com is a privately owned, operated and funded community.