Last active
September 6, 2017 23:07
-
-
Save tylerburdsall/29b0e036eaeae66c007e8af128840a89 to your computer and use it in GitHub Desktop.
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
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) | |
count = len(flavors) | |
flavors_and_links = [] | |
links = soup.find('section', attrs={'class':'content-area clear portland'}).findAll('a', href=True) | |
for i in range(count): # new changes | |
print("{} - {}".format(flavors[i], links[i]['href'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment