-
-
Save pybites/8bd9fdd28aef02024c658d1b33ccabe5 to your computer and use it in GitHub Desktop.
PyBites.py
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
"""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