How to extract data from an embed Raphael dataset to CSV?

前提是你 提交于 2019-12-12 19:17:03

问题


Attempting to extract the data from this Google Politics Insights webpage from "Jan-2012 to the Present" for Mitt Romney and Barack Obama for the following datasets:

  • Search Trends Based on volume
  • Google News Mentions Mentions in articles and blog posts
  • YouTube Video Views Views from candidate channels

For visual example, here's what I mean:

Using Firebug I was able to figure out the data is stored in a format readable by Raphael 2.1.0; looked at the dataset and nothing strikes me as a simple way to convert the data to CSV.

How do I convert the data per chart per presidential candidate into a CSV that has a table for "Search Trends", "Google News Mentions", and "YouTube Video Views" broken down by the smallest increment of time with the results measured in the graph are set to a value of "0.0 to 1.0"? (Note: The reason for "0.0 to 1.0" is the graphs do not appear to give volume info, so the volume is relative to the height of the graph itself.)

Alternatively, if there's another source for all three datasets in CSV, that would work too.


回答1:


First thing to do is to find out where the data comes from, so I looked up the network traffic in my developer console, and found it very soon: The data is stored as json here.

Now you've got plenty of data for each candidate. I don't know exactly in what relation these numbers are but they definitely are used for their calulation in the graph. I found out that the position in the main.js is on line 392 where they calculate the data with this expression:

Math.log(dataPoints[i][j] * 100.0) / Math.log(logScaleBase);

My guess is: Without the logarithm and a bit exponential calculation you should get the right results.



来源:https://stackoverflow.com/questions/11954091/how-to-extract-data-from-an-embed-raphael-dataset-to-csv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!