Skip to content

Instantly share code, notes, and snippets.

@pybites
Forked from clamytoe/PyBites.py
Last active June 4, 2017 18:19
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 pybites/8bd9fdd28aef02024c658d1b33ccabe5 to your computer and use it in GitHub Desktop.
Save pybites/8bd9fdd28aef02024c658d1b33ccabe5 to your computer and use it in GitHub Desktop.
PyBites.py
"""Written on iPhone with the Pythonista 3 app
As a joke for the PyBites guys, I don't see why it wouldn't work anywhere else though. They always
start off their newsletter annoucements with:
from @PyBites import newsletter
So I turned it into actual code that pulls their feed and opens their latest newsletter in a browser :)
"""
import webbrowser
from bs4 import BeautifulSoup
import requests
def newsletter():
"""Parses rss feed
It pulls out the articles and displays their title, link, and description.
"""
# link to the newsletter
url = 'http://us14.campaign-archive2.com/home/?u=822043293f280259d4b8d2a3e&id=ac7e2eb9ef'
# retrieve page and extract content
r = requests.get(url)
html = r.text
# turn into soup object
soup = BeautifulSoup(html, 'html.parser')
article = soup.find('li', class_='campaign').a['href']
# open up the latest one
webbrowser.open(article)
newsletter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment