mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update cacm.recipe
No need for username-password. Articles are free to read and can be retrieved from the RSS feed.
This commit is contained in:
parent
b49064d6b6
commit
85c1c53a53
@ -1,39 +1,30 @@
|
|||||||
import datetime
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class CACM(BasicNewsRecipe):
|
||||||
class AdvancedUserRecipe1286242553(BasicNewsRecipe):
|
title = "ACM CACM Magazine"
|
||||||
title = u'CACM'
|
description = "Published on day 1 of every month."
|
||||||
oldest_article = 7
|
oldest_article = 30
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
needs_subscription = True
|
auto_cleanup = True
|
||||||
feeds = [(u'CACM', u'http://cacm.acm.org/magazine.rss')]
|
|
||||||
language = 'en'
|
feeds = [
|
||||||
__author__ = 'jonmisurda'
|
('ACM CACM', 'https://cacm.acm.org/magazine.rss'),
|
||||||
no_stylesheets = True
|
|
||||||
remove_tags = [
|
|
||||||
dict(name='div', attrs={'class': ['FeatureBox', 'ArticleComments', 'SideColumn',
|
|
||||||
'LeftColumn', 'RightColumn', 'SiteSearch', 'MainNavBar', 'more', 'SubMenu', 'inner']})
|
|
||||||
]
|
]
|
||||||
cover_url_pattern = 'http://cacm.acm.org/magazines/%d/%d'
|
|
||||||
|
|
||||||
def get_browser(self):
|
|
||||||
br = BasicNewsRecipe.get_browser(self)
|
|
||||||
if self.username is not None and self.password is not None:
|
|
||||||
br.open('https://cacm.acm.org/login')
|
|
||||||
br.select_form(nr=1)
|
|
||||||
br['current_member[user]'] = self.username
|
|
||||||
br['current_member[passwd]'] = self.password
|
|
||||||
br.submit()
|
|
||||||
return br
|
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
now = datetime.datetime.now()
|
"""
|
||||||
|
Parse out cover URL from cover page.
|
||||||
|
Example:
|
||||||
|
From: https://cacm.acm.org/system/assets/0004/2570/April2022.Cover.1000x1338.large.jpg?1647524668&1647524668
|
||||||
|
Get: https://cacm.acm.org/system/assets/0004/2570/April2022.Cover.1000x1338.jpg
|
||||||
|
"""
|
||||||
|
|
||||||
cover_url = None
|
soup = self.index_to_soup("https://cacm.acm.org/")
|
||||||
soup = self.index_to_soup(self.cover_url_pattern %
|
a_img = soup.find("a", class_="menuCover")
|
||||||
(now.year, now.month))
|
img_url = a_img.img["src"]
|
||||||
cover_item = soup.find('img', attrs={'alt': 'magazine cover image'})
|
img_url = img_url.split("?")[0]
|
||||||
if cover_item:
|
img_url = img_url.replace(".large", "")
|
||||||
cover_url = cover_item['src']
|
return img_url
|
||||||
return cover_url
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user