Skip to content

Instantly share code, notes, and snippets.

@yurivictor
Last active September 30, 2018 13:28
Show Gist options
  • Save yurivictor/7798679 to your computer and use it in GitHub Desktop.
Save yurivictor/7798679 to your computer and use it in GitHub Desktop.
Scrape your @Medium post links into HTML list, if you want to add them to your site, or whatever
import requests
from pyquery import PyQuery as pq
USERNAME = 'ev' # change to your username
def get_medium_posts():
url = 'http://medium.com/@' + USERNAME + '/latest'
request = requests.get( url )
html = request.content
return pq( html )( '.post-item-title h3 a' )
def show_medium_posts():
posts = get_medium_posts()
html = '<ul>'
for post in posts:
url = 'http://medium.com' + post.attrib['href']
headline = pq( post ).text()
html += '<li><a href="' + url + '">' + headline + '</a></li>'
html += '</ul>'
print html
show_medium_posts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment