Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 12-08-2010, 05:04 AM   #1
Stomking
Junior Member
Stomking began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Dec 2010
Device: marcus.klemm@googlemail.com
Instapaper.com: Archive downloaded articles

Hi,

Is it possible to modify the Instapaper.com recipe so that successfully downloaded articles are moved to Instapaper's archive, automatically?

Unfortunately, I only have very basic programming skills and never used python, before. Nonetheless, I tried to do the following:

Code:
def parse_index(self):
        totalfeeds = []
        lfeeds = self.get_feeds()
        for feedobj in lfeeds:
            feedtitle, feedurl = feedobj
            self.report_progress(0, _('Fetching feed')+' %s...'%(feedtitle if feedtitle else feedurl))
            articles = []
            soup = self.index_to_soup(feedurl)
            for item in soup.findAll('div', attrs={'class':'titleRow'}):
                description = self.tag_to_string(item.div)
                atag = item.a
                if atag and atag.has_key('href'):
                    url         = atag['href']
                    title       = self.tag_to_string(atag)
                    date        = strftime(self.timefmt)
                    articles.append({
                                      'title'      :title
                                     ,'date'       :date
                                     ,'url'        :url
                                     ,'description':description
                                    })
            totalfeeds.append((feedtitle, articles))
            for item in soup.findAll('a', attrs={'class':'archiveButton'}): // Get all links with class "archiveButton"
        	skipurl = item['href']                                                 // get the repective URLs
        	self.index_to_soup(skipurl)                                         // 'click' on them
        return totalfeeds
As I expected, it didn't work. So can someone point me into the right direction?
Stomking is offline   Reply With Quote
Old 12-08-2010, 10:06 AM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Stomking View Post
can someone point me into the right direction?
It looks like you want to click on a link on a page. Typically that's done by setting up a browser (br), opening the page (url), finding the link on that page with a regex (url_regex) and using follow_link:

Code:
        br = self.get_browser()
        br.open(url)
        response = br.follow_link(url_regex='some_regex)', nr = 0)
Starson17 is offline   Reply With Quote
Advert
Old 04-14-2011, 10:56 PM   #3
banjopicker
Member
banjopicker began at the beginning.
 
banjopicker's Avatar
 
Posts: 24
Karma: 10
Join Date: May 2007
Device: PRS-505
The following is a python script I wrote to download instapaper articles with the Calibre recipe, save them as an epub, and then archive all instapaper articles so that it won't keep re-downloading the same ones.

There is probably a simpler way to do this, but I am a Python novice, and learned just enough to get it to work.

You will need to have urllib and urllib2 libraries installed in Python for this to work. You will also need to change the username/password and form_key fields to your own. I also have the windows path to Calibre hard-coded in the script--change it if Calibre is in a different directory for you.

Code:
import datetime, subprocess
from urllib import urlencode
import urllib2

myUsername = "youremail@yourprovidor.com" 
myPassword = "yourpass"
myForm_Key = "8IL7UWrLhP3l2fmD2SZg" #Unique value probably linked to username/pass -- you must change this

#You get myForm_Key by logging in to Instapaper one time, looking at the 
#source of the HTML page, finding the form_key value, and pasting it here.
#Maybe if people find this script useful I will have it automate the task.

#construct a windows command-line command to use Calibre with Instapaper
todayDate = datetime.date.today().isoformat()
myFilename = 'Instapaper ' + todayDate + '.epub'
params2 = urlencode(dict(form_key=myForm_Key, submit="Archive All"))
mySystemCommand = 'C:\Program Files\calibre2\ebook-convert Instapaper.com.recipe "' + myFilename + '" --username ' + myUsername + ' --password ' + myPassword

#execute Calibre command
ret = subprocess.call(mySystemCommand)

#login to Instapaper so that downloaded archives can now be archived
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)

params = urlencode(dict(username=myUsername, password=myPassword))
f = opener.open('http://www.instapaper.com/user/login', params)
data = f.read()
f.close()

#archive all articles in unread folder
f=opener.open("http://www.instapaper.com/bulk-archive", params2)
data2=f.read()
f.close()
banjopicker is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre + Instapaper not downloading all articles! Maxiboost Recipes 34 08-02-2011 08:03 AM
Troubleshooting Instapaper -- I think I've tried EVERYTHING Timmy_B Amazon Kindle 9 01-22-2011 10:35 AM
Syncing your Instapaper articles to your Kindle Jeton Amazon Kindle 0 10-08-2010 03:28 AM
Calibre, Instapaper, multipage articles and ordering flyash Calibre 1 06-10-2010 07:03 PM
Is There A Way To Archive Books Downloaded Barry8416 Sony Reader 10 08-19-2009 01:41 PM


All times are GMT -4. The time now is 04:49 AM.


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