I am trying to extract the "Company & Tests" values from this Web page: https://public.tableau.com/views/v_7_14_2020/COVID-19TestingCommons
The preferred output would be a array with company and number of tests for each company.
There is another thread (How can I scrape tooltips value from a Tableau graph embedded in a webpage) with a similar question..
I tried to work with that and it didn't work in my case
Thank You.
import requests
from bs4 import BeautifulSoup
import json
import time
data_host = "https://public.tableau.com"
r = requests.get(
f"{data_host}/views/v_7_14_2020/COVID-19TestingCommons",
params= {
":showVizHome":"no",
}
)
soup = BeautifulSoup(r.text, "html.parser")
tableauData = json.loads(soup.find("textarea",{"id": "tsConfigContainer"}).text)
dataUrl = f'{data_host}{tableauData["vizql_root"]}/bootstrapSession/sessions/{tableauData["sessionid"]}'
r = requests.post(dataUrl, data= {
"sheet_id": tableauData["sheetId"],
})
dataReg = re.search('\d+;({.*})\d+;({.*})', r.text, re.MULTILINE)
info = json.loads(dataReg.group(1))
data = json.loads(dataReg.group(2))
print(data["secondaryInfo"]["presModelMap"]["dataDictionary"]["presModelHolder"] ["genDataDictionaryPresModel"]["dataSegments"]["0"]["dataColumns"])