Skip to content

Instantly share code, notes, and snippets.

@cquest
Last active April 8, 2018 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cquest/5817731dd6342574480ac5f80f4e8f52 to your computer and use it in GitHub Desktop.
Save cquest/5817731dd6342574480ac5f80f4e8f52 to your computer and use it in GitHub Desktop.
python script to retrieve a user's curated scoops on scoop.it
import json
import requests
from bs4 import BeautifulSoup
import sys
scoop = sys.argv[1] # ex: https://www.scoop.it/u/user-login
pages = int(sys.argv[2]) # number of pages to retrieve
for page in range(0, pages):
req = requests.get(scoop + "/ajaxGetLastPublishedPosts?showPaginator=truelistId=curatedPostsTab&view=json&page=%s" % (page+1,))
j = json.loads(req.text)
h = BeautifulSoup(j['js_inner_replace']['html'], 'lxml')
for post in h.find_all(class_='post'):
try:
meta = post.find(class_='post-metas')
out = dict()
out['url'] = post.h2.a.get('href')
out['title'] = post.h2.a.text.strip()
out['meta'] = meta.span.a.get('href')
out['date'] = meta.span.a.text.strip()
print(json.dumps(out))
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment