Skip to content

Instantly share code, notes, and snippets.

@offsetkeyz
Created May 12, 2020 02:28
Show Gist options
  • Save offsetkeyz/e9e7b93625cce1bf28d45b042cd8e015 to your computer and use it in GitHub Desktop.
Save offsetkeyz/e9e7b93625cce1bf28d45b042cd8e015 to your computer and use it in GitHub Desktop.
Requests with Beautiful Soup
_author_ = "Colin McAllister (Offset Colin)"
import requests
from bs4 import BeautifulSoup
request = requests.get("https://www.johnlewis.com/herman-miller-aeron-office-chair-graphite/p3177252")
content = request.content
soup = BeautifulSoup(content, "html.parser")
element = soup.find("p", "price price--large")
price = float(element.text.strip('£').replace(',', ''))
print(price)
#<p class="price price--large">£1,099.00</p>
# print(request.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment