简体   繁体   中英

Python scrape dynamic table from website?

I'm trying to get info from a table which values change given some inputs (you have to choose the date of analysis)

I've never get info from a "dynamic" table so I haven't got anywhere

from bs4 import BeautifulSoup

from urllib.request import urlopen, Request

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3'}

reg_url = "http://www.cmfchile.cl/institucional/mercados/entidad.php?mercado=V&rut=9117&grupo=&tipoentidad=FIRES&row=AAAw%20cAAhAABP4LAAU&vig=VI&control=svs&pestania=7"

req = Request(url=reg_url, headers=headers) 

html = urlopen(req).read() 

soup = BeautifulSoup(html)

I think that you can't get dynamic data with BeautifulSoup.

You should better use Selenium for this, you can change your dates to whatever you want, then get any elements that you will need.

Check this out: How to retrieve the values of dynamic html content using Python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM