When I try to scrape the price of a product, it returns zero

Viewed 22

I am trying to scrape the price of a product of a website but when I try to scrape it, it returns zero.

Here is the website. How can I extract the price?

Here is my code:

import requests
from bs4 import BeautifulSoup
from time import sleep


def maple_leaf_1(url, coins, n):
    r = requests.get(url)
    soup = BeautifulSoup(r.text, "html.parser")
    sleep(3)
    coin_name = soup.find("span", class_="base").text
    coin_price = soup.find("span", class_="price").text
    coins[n].insert(0, url)
    coins[n].insert(1, coin_name)
    coins[n].insert(2, coin_price)


def main():
    coins = [[]]
    maple_leaf_1("https://goldstocklive.com/1-oz-gold-2021-maple-leaf-coin.html", coins, 0)
    print(coins)

if __name__ == "__main__":
    main()
0 Answers
Related