The page I'm trying to scrape from is https://www.investagrams.com/Stock/ac and I'm trying to get the price value (779.00) but my code only returns: {{ViewStockPage.Data.Stock.LatestStockHistory.Last | numberPriceFormat}}
My code:
from bs4 import BeautifulSoup
import requests
r = requests.get('https://www.investagrams.com/Stock/ac')
soup = BeautifulSoup(r.text, "lxml")
main = soup.find('div', class_= 'd-flex flex-row justify-content-between')
header = main.find('h4', class_= 'mb-0')
price = header.find('span', class_= 'mr-2').string
print(price)
Website HTML:
<h4 class="mb-0">
<small class="ng-binding">Ayala Corporation (PSE:AC) </small> <br>
<strong>
<span class="mr-2 ng-binding" data-ng-class="ViewStockPage.Data.Stock.LatestStockHistory.LastClass">779.00 </span>
<span data-ng-class="{'stock-up-caret stockprice-up' : ViewStockPage.Data.Stock.LatestStockHistory.ChangePercentage > 0, 'stock-down-caret stockprice-down' : ViewStockPage.Data.Stock.LatestStockHistory.ChangePercentage < 0, 'glyphicon glyphicon-minus stockprice-flat': ViewStockPage.Data.Stock.LatestStockHistory.ChangePercentage == 0}" class="stock-down-caret stockprice-down" style=""> </span>
<span style="font-size: 13px; vertical-align: middle;" data-ng-class="{'stockprice-up' : ViewStockPage.Data.Stock.LatestStockHistory.ChangePercentage > 0, 'stockprice-down' : ViewStockPage.Data.Stock.LatestStockHistory.ChangePercentage < 0, 'stockprice-flat': ViewStockPage.Data.Stock.LatestStockHistory.ChangePercentage == 0}" class="stockprice-down">
<span class="ng-binding">-21.00 </span>
<span class="ml-1 ng-binding">-2.62% </span>
</span>
</strong>
</h4>