Skip to content

Instantly share code, notes, and snippets.

@kristianperkins
Created August 30, 2015 23:16
Show Gist options
  • Save kristianperkins/1f43790b6a77e92292b5 to your computer and use it in GitHub Desktop.
Save kristianperkins/1f43790b6a77e92292b5 to your computer and use it in GitHub Desktop.
display a random horoscope from the onion website
import random
from bs4 import BeautifulSoup
import requests
b = BeautifulSoup(requests.get('http://www.theonion.com/features/horoscope').text, 'html.parser')
astro = random.choice(b.findAll("li", {"class": "astro"}))
print(astro.find('div', {'class': 'large-thing'}).get_text())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment