Skip to content

Instantly share code, notes, and snippets.

@Chandler
Last active May 11, 2016 22:36
Show Gist options
  • Save Chandler/f69792dde8367553ade1 to your computer and use it in GitHub Desktop.
Save Chandler/f69792dde8367553ade1 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
# from terminal
# curl http://www.flowerexplosion.com/by-flower/roses.html?p=[1-11] > roses.html
# python scrape.py
filename = "roses.html"
with open (filename, "r") as infile:
html = BeautifulSoup(infile.read())
tables = html.find_all("table", class_="generic-product-grid")
for table in tables:
rows = table.find_all("tr")
for row in rows:
cells = row.find_all("td")
for cell in cells:
title = cell.find_all("a")[1].text
price = cell.find_all("span", class_="price")[0].text
print title + ", " + price.lstrip().rstrip()
# Freedom Red Rose , $60.00
# Samarcanda | Red Garden Rose, $89.00
# Imagination Rose, $60.00
# Patience Beige English Rose | David Austin (TM), $134.99
# Phoebe Pink English Rose | David Austin (TM), $134.99
# Ocean Song Lavender Rose, $60.00
# Miranda Light Pink English Rose | David Austin (TM), $134.99
# Juliet Peach English Rose | David Austin (TM), $134.99
# Cool Water Lavender Rose, $49.99
# Caramel Antique | Beige Spray Garden Rose, $105.00
# Yellow Spray Roses, $88.00
# Red Unique Red Rose, $60.00
# Eskimo White Rose , $60.00
# Walzertraum | Hot Pink Garden Rose, $89.00
# Classic Woman | Cream Garden Rose, $89.00
# Amsterdam Salmon Rose, $60.00
# Kerio Yellow Rose, $60.00
# Hot Princess Pink Rose , $60.00
# Faith Lavender Antique Rose, $60.00
# Silverstone Lavender Rose, $60.00
# Sweetness Pink and White Rose, $60.00
# Red Intuition Rose (Exclusive), $60.00
# Cotton Candy Tinted Roses, $75.00
# Mount Everest White Rose , $60.00
# Black and Red Tinted Roses, $64.99
# Keira Pink English Rose | David Austin (TM), $134.99
# Pink Antique | Pink Garden Rose, $89.00
# Pink Preserved Roses, $85.00
# Dark Pink Edible Rose , $79.00
# Amnesia Lavender Antique Rose, $60.00
# Limbo Green Rose, $60.00
# Super Green Garden Roses, $89.00
# Pink and White Spray Roses, $88.00
# Orange and Peach Spray Roses, $88.00
# Free Spirit | Orange Garden Roses, $114.99
# Red and Yellow Tinted Roses, $64.99
# High Society Red and Cream Rose, $60.00
# Mondial White Rose , $60.00
# Lavender Spray Roses, $88.00
# Polar Star White Rose, $60.00
# Alex Orange and Cream Rose, $60.00
# Red Rose Petals, $75.00
# Royal Circus Yellow and Red Rose, $49.99
# Crème de la Crème Rose , $60.00
# Tinto Red Rose, $60.00
# Tinted Blue Roses, $75.00
# Carrousel Red and Cream Rose, $60.00
# Topaz Hot Pink Rose , $49.99
# Aqua Lavender Rose , $60.00
# Talea Cream Rose, $60.00
# Jeanne-Moreau | Ivory Garden Roses, $89.00
# Movie Star Orange Rose, $60.00
# Cherry Love Red Rose, $60.00
# Estelle Terracotta Rose, $60.00
# Yellow and Blue Tinted Roses, $75.00
# Capriccio | Yellow Garden Roses, $89.00
# Impulse Orange Rose, $60.00
# High Booming Salmon Rose, $60.00
# Purple Fragrance | Lavender Garden Rose, $89.00
# Candlelight | Yellow Creamy Garden Roses, $89.00
# Cream Spray Roses , $88.00
# Luna Rosa Red Rose, $60.00
# Alicia Light Pink Rose, $60.00
# Purple and White Tinted Roses, $75.00
# Lollipop Tinted Roses, $75.00
# Cinnamon Peach Rose, $60.00
# Tricolor Tinted Roses, $75.00
# Fenice Pink Rose, $60.00
# Darcey Red English Rose | David Austin (TM), $134.99
# Purple Cezanne Rose , $60.00
# Classic Cezanne Rose , $60.00
# Tinted Rainbow Roses, $64.99
# Cezanne Rose, $60.00
# O’Hara Pink Rose, $77.00
# Green Tea Rose, $60.00
# Blue Bird Lavender Rose , $60.00
# Hot Lady Pink Rose, $60.00
# Geisha Yellow and Pink Rose, $60.00
# Blizzard White Rose , $60.00
# Raphaela Pink Rose , $60.00
# Manitou Orange Rose, $60.00
# Piano | Red Spray Garden Roses, $105.00
# Vendela Ivory Rose, $60.00
# Konfetti Red and Yellow Rose, $60.00
# Soutine Rose (Exclusive), $77.00
# Black Baccara Red Rose, $60.00
# Yves Piaget | Hot Pink Garden Rose, $89.00
# Engagement Pink Rose, $60.00
# Long Arifa Pink and White Rose, $60.00
# Cream and Light Pink Spray Roses, $88.00
# Helio Yellow and Red Rose, $60.00
# Brazil Yellow Rose, $60.00
# White Spray Roses, $88.00
# Orange Spray Roses, $88.00
# Yellow and Purple Tinted Roses, $75.00
# Gold Strike Yellow Rose, $60.00
# Latin Beauty Red and Cream Rose, $60.00
# Red Spray Roses, $88.00
# Leonidas Terracotta and Cream Rose, $60.00
# Blue Curiosa Lavender Rose , $49.99
# Cherry Oh! Pink Rose , $60.00
# Tinted Green Roses, $75.00
# Tibet Ivory Rose, $60.00
# Voodoo Orange Rose, $60.00
# Polo White Rose, $60.00
# Conga Yellow Rose, $60.00
# Tabasco Cream and Pink Rose, $60.00
# High & Orange Rose, $60.00
# Tropical Amazone Orange Rose, $60.00
# Orange Splash Multicolor Rose (Exclusive), $75.00
# Coffee Break Rose, $60.00
# Tinted Black Roses, $64.99
# Deja Vu Yellow Rose, $60.00
# Tinted Purple Roses, $75.00
# High Magic Yellow and Red Rose, $60.00
# Blush Pink and White Rose, $60.00
# Friendship Red and Orange Rose, $60.00
# Titanic Light Pink Rose, $60.00
# Viva Yellow Rose, $60.00
# Black Magic Red Rose, $60.00
# Anastasia White Rose, $60.00
# Pink Intuition Rose (Exclusive), $45.00
# Red Diamond Rose, $60.00
# Forever Young Red Rose, $60.00
# Hot Pink and Cream Spray Roses, $88.00
# Green Spray Roses, $88.00
# Light Pink Spray Roses, $88.00
# Peach Spray Roses, $88.00
# Dark Red Spray Roses, $88.00
# Hot Pink Spray Roses, $88.00
# Salmanasar | Garden Roses, $89.00
# Francois Rabelais | Red Garden Rose, $89.00
# Kate Hot Pink English Rose | David Austin (TM), $134.99
# Toulouse Lautrec | Yellow Garden Rose, $89.00
# Vitality | White Garden Rose, $89.00
# Shalimar | Lavender Garden Rose, $89.00
# Creamy White | Spray Garden Rose, $89.00
# Campanella | Peach Garden Roses, $114.99
# Rossini Rose , $60.00
# Devotion Red Rose, $60.00
# Aubade Pink and White Rose, $60.00
# Sophie Pink Rose , $60.00
# Jade Green Rose, $60.00
# Star 2000 Orange Rose, $60.00
# Shocking Versillia Hot Pink Rose , $60.00
# Halloween Rose Combo!, $99.00
# Custom Tinted Roses, $64.99
# Mixed Tinted Roses, $120.00
# Christmas Tinted Roses, $75.00
# Independence Day Roses, $75.00
# Hot Pink Preserved Roses, $85.00
# Yellow Preserved Roses, $85.00
# Blue Preserved Roses, $85.00
# Lavender Preserved Roses, $85.00
# Green Preserved Roses, $85.00
# Mixed Preserved Roses, $89.00
# White Edible Rose , $79.00
# Red Edible Rose , $79.00
# Pale Pink Edible Rose , $79.00
# Cream Rose Petals, $75.00
# Yellow Rose Petals, $75.00
# Orange Rose Petals, $75.00
# Hot Pink Rose Petals, $75.00
# Light Pink Rose Petals, $75.00
# Green Rose Petals, $75.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment