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-20-2021, 05:10 PM   #1
rasteps
Zealot
rasteps began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2010
Device: Kindle, Android phone
New York Times Cooking [submission]

This recipe was originally created by @Gourav. I have been using it for months now and it works great. I set it to download once a week on Sunday and I get a great weekly recipe magazine. So I would like to submit it for the official downloads.




#!/usr/bin/env python
# vim:fileencoding=utf-8
from calibre.web.feeds.news import BasicNewsRecipe

class NYTCooking(BasicNewsRecipe):
title = 'NY Times Cooking'
description = 'NY Times Cooking Magazine'
__author__ = 'gourav'
oldest_article = 2
max_articles_per_feed = 30
auto_cleanup = True
auto_cleanup_keep = '//div[@class="recipe-intro"]|'\
'//div[@class="recipe-instructions"]|'

def parse_index(self):
url = 'https://cooking.nytimes.com/topics/what-to-cook-this-week'
br = self.get_browser()
response = br.open(url)
html = response.read()
soup = BeautifulSoup(html)

articles = soup.find_all('div', class_='card-info-wrapper')
feed = []

for i in articles:
article = {}
article['url'] = i.find('a')['href']
if article['url'].startswith('/'):
article['url'] = 'https://cooking.nytimes.com' + article['url']
article['title'] = i.find('h3').text.strip()
author = i.find('p', class_='card-byline')
article['author'] = author.text if author is not None else 'Unknown'
feed.append(article)

return [('Recipes', feed)]
rasteps is offline   Reply With Quote
Old 08-20-2021, 11:12 PM   #2
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: 45,343
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...c734b1912a193a
kovidgoyal is online now   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NY Times Cooking [recipe request] rasteps Recipes 4 08-17-2021 10:38 AM
The New York Times Vikas Chahal Recipes 0 05-09-2021 03:55 AM
6 Days for Better Cooking is FREE - cooking tips book thestubborndev Self-Promotions by Authors and Publishers 0 12-26-2014 11:55 AM
Seattle Times Recipe not cooking? daletsteele Recipes 1 12-31-2011 09:45 PM
Free book (Kindle/Nook/Sony) - Slow Cooking by Gooseberry Patch [Cooking] ATDrake Deals and Resources (No Self-Promotion or Affiliate Links) 3 11-28-2011 04:51 PM


All times are GMT -4. The time now is 11:03 PM.


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