-
-
Save nealrs/2f23b91b64e40e6f7b9c to your computer and use it in GitHub Desktop.
Python script + cron job to add NextDraft articles to your Instagram list every day at 5:05pm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 5 17 ? * MON-FRI * python ~/path/instadraft.py >> ~/path/instadraft.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This script will add every article from the current issue of NextDraft to your Instapaper list. Remember to change the l/p variables (if you don't have a password (you probably don't), you can leave p blank). FYI, NextDraft usually comes out weekdays between 3-4pm ET. | |
# Hi, I'm Neal (@nealrs on the interwebs). Earlier this week I made a PHP webapp that does this for Pocket (nextdraftpocket.com). And while that's cool, Instapaper's Simple API is stupid easy to use, lot's of people prefer IP, and I figured I could automate this as a cron job anyway. So here we are. | |
import requests | |
from lxml import html | |
from time import strftime | |
nd = html.fromstring(requests.get('http://nextdraft.com/current').content) | |
urls = nd.xpath('//div[@class="blurb-content"]/p/a/@href') | |
l = "[email protected]" # required -- usually your email address | |
p = "" # optional (most people don't have passwords) | |
print strftime("%Y-%m-%d %H:%M:%S")+" | Ok "+ l + ", let's do this!" | |
for u in urls: | |
print "Adding "+u+" to Instapaper" | |
r = requests.get('https://www.instapaper.com/api/add?username='+l+'&password='+p+'&url='+u) | |
print r.content | |
print strftime("%Y-%m-%d %H:%M:%S")+" | Dunzo." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment