How to detect functions in the browser

Asked

Viewed 45 times

0

I am developing a web scrapper in python that will take the data of a stock chart every 30 min and send me an email telling me if the action has varied positively or negatively, however, I got the following problem: How do I get the action canvas data? I know there is a function (probably JS) that inserts the new values into the canvas, and it is precisely here that my doubt comes, has as I see by the browser, or even by the IDE which function is updating the canvas?

This is the site: http://www.b3.com.br/pt_br/market-data-e-indices/servicos-de-dados/market-data/cotacoes/

And that’s all the code I’ve done so far:

import requests
from bs4 import BeautifulSoup

url = 'http://www.b3.com.br/pt_br/market-data-e-indices/servicos-de-dados/market-data/cotacoes/'

site = requests.get(url=url)

soup = BeautifulSoup(site.content, "html.parser")

scripts = soup.find_all('script')

print(len(scripts))

Returns 40 which are all scripts you have on the page.

Many are just the tag indicating the function file without the body of the function itself and to parse all 40 tags and search each directory will be at least time consuming, so I appreciate if you(a) know a way to see the function that updates this canvas

1 answer

2

Beautifulsoup does not allow you to read javascript. If you can extract text from the script you are looking for, you would have to use regex to get the desired value. To read javascript code there is Phantomjs or Selenium.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.