Skip to content

Instantly share code, notes, and snippets.

@tylerburdsall
Last active September 6, 2017 22:59
Show Gist options
  • Save tylerburdsall/4cd3a58e12e19b165af154a827e1e0a7 to your computer and use it in GitHub Desktop.
Save tylerburdsall/4cd3a58e12e19b165af154a827e1e0a7 to your computer and use it in GitHub Desktop.
from urllib.request import urlopen
from bs4 import BeautifulSoup
website = 'https://saltandstraw.com/flavors/'
page = urlopen(website)
soup = BeautifulSoup(page, 'html.parser')
results = soup.find('section', attrs={'class':'content-area clear portland'}).findAll('div', attrs={'class':'entry-title'})
flavors = []
for title in results:
flavors.append(title.text)
# new code below
count = len(flavors)
flavors_and_links = []
links = soup.find('section', attrs={'class':'content-area clear portland'}).findAll('a', href=True)
for link in links:
print(link['href'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment