Skip to content

Instantly share code, notes, and snippets.

@ugeugeHigh
Created January 8, 2023 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugeugeHigh/13aab99e9a376ede0c5bfbc673cc7197 to your computer and use it in GitHub Desktop.
Save ugeugeHigh/13aab99e9a376ede0c5bfbc673cc7197 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
class switch_s:
def __init__(self):
global soup
url = "https://www.switch-science.com/products/8522"
r = requests.get(url)
soup = BeautifulSoup(r.content,"html.parser")
def stock(self):
global soup
tmp = soup.find_all('p')
a = str(tmp[5])
tmp1 = a.split('>')
tmp2 = tmp1[1].split('<')
stock = str(tmp2[0])
return stock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment