bertrandmartel / tableau-scraping

Tableau scraper python library. R and Python scripts to scrape data from Tableau viz
MIT License
131 stars 21 forks source link

add missing method for command `select-region-no-return-server` #51

Open wasdee opened 2 years ago

wasdee commented 2 years ago

this is the example curl of it.

curl 'https://public.tableau.com/vizql/w/moph_covid_v3/v/Story1/sessions/42D45C5A5CE64D568F6A9FC5E4B49538-0:0/commands/tabsrv/select-region-no-return-server' \
  -H 'authority: public.tableau.com' \
  -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Microsoft Edge";v="96"' \
  -H 'x-tsi-active-tab: Story%201' \
  -H 'x-newrelic-id: XA4CV19WGwIBV1RVBQQBUA==' \
  -H 'x-xsrf-token: VKwCIrLfvwR3CEuxIjzKRObYjUdnikog' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62' \
  -H 'content-type: multipart/form-data; boundary=fHyp2ZJG' \
  -H 'accept: text/javascript' \
  -H 'x-requested-with: XMLHttpRequest' \
  -H 'sec-ch-ua-platform: "Windows"' \
  -H 'origin: https://public.tableau.com' \
  -H 'sec-fetch-site: same-origin' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-dest: empty' \
  -H 'referer: https://public.tableau.com/views/moph_covid_v3/Story1?%3Adisplay_static_image=y&%3AbootstrapWhenNotified=true&%3Aembed=true&%3Alanguage=en-US&:embed=y&:showVizHome=n&:apiID=host0' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cookie: _ga=GA1.2.1052995761.1640085245; _ga=GA1.3.1052995761.1640085245; _gcl_au=1.1.1745605423.1640093530; _fbp=fb.1.1640093531449.1204649223; seerid=3063ccc8-baa5-438d-8b18-3e590ecba6dc; ELOQUA=GUID=3A902EAE177F48259C6773185FBA384F; tableau_public_negotiated_locale=en-us; _gid=GA1.2.1491619847.1640332454; _gid=GA1.3.1491619847.1640332454; tableau_locale=en; tableau_xsrf_token=yWJgBuoqlShwu1eBrV0qMyZksxxH7ew4; tableau_client_id=2b11338d-0ee2-40df-980c-ffc7b1bc48ec; tableau_access_token=heh8YOUFSt2k0LtQxXikyQ|NC3bh1ap1NvqxvBbPurVV3GWrzUuU8eQ; tableau_refresh_token="3PtDoccuQYSeq2+QE1UQfQ==:OukH9ADVg9lhCkWvgw0qApSHlyYoPMC0"; workgroup_session_id=null; XSRF-TOKEN=VKwCIrLfvwR3CEuxIjzKRObYjUdnikog' \
  --data-raw $'--fHyp2ZJG\r\nContent-Disposition: form-data; name="visualIdPresModel"\r\n\r\n{"worksheet":"province_total","dashboard":"Dashboard_Province_index_new_v3","storyboard":"Story 1","storyPointId":12}\r\n--fHyp2ZJG\r\nContent-Disposition: form-data; name="vizRegionRect"\r\n\r\n{"x":120,"y":130,"w":0,"h":0,"r":"yheader"}\r\n--fHyp2ZJG\r\nContent-Disposition: form-data; name="mouseAction"\r\n\r\nsimple\r\n--fHyp2ZJG\r\nContent-Disposition: form-data; name="zoneSelectionType"\r\n\r\nreplace\r\n--fHyp2ZJG\r\nContent-Disposition: form-data; name="dashboardPm"\r\n\r\n{"sheetName":"Dashboard_Province_index_new_v3","isDashboard":true,"storyboard":"Story 1","storyPointId":12}\r\n--fHyp2ZJG\r\nContent-Disposition: form-data; name="zoneId"\r\n\r\n96\r\n--fHyp2ZJG--\r\n' \
  --compressed

this selection happens when I click on the list. It will filter data.

reproduce

on https://public.tableau.com/app/profile/karon5500/viz/moph_covid_v3/Story1 click on any items on the rightmost list.

bertrandmartel commented 2 years ago

@CircleOnCircles Sorry for late reply. The select-region-no-return-server call needs the mouse coordinate to correctly work which is very hard to assume in this case

I see that the correct would be to use the select call on the province name like:

province_ws = workbook.getWorksheet("province_total")
wb = province_ws.select("Prov Name", "นครราชสีมา")

I will fix the bug relating to #48