Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there anyway to have a date parameter for trendData() ? #28

Closed
ghost opened this issue Oct 6, 2016 · 7 comments · Fixed by #33
Closed

Is there anyway to have a date parameter for trendData() ? #28

ghost opened this issue Oct 6, 2016 · 7 comments · Fixed by #33

Comments

@ghost
Copy link

ghost commented Oct 6, 2016

In order to see trend data for a keyword in a given time frame e.g. past year, past month, past week.

I noticed it wasn't in the documentation, also didn't work when I tested it.

@pat310
Copy link
Owner

pat310 commented Oct 6, 2016

@SuttJ Not at this point, but I'm hoping to add this functionality soon. I'll let you know when I do!

@ghost
Copy link
Author

ghost commented Oct 6, 2016

Thanks! - I was gonna poke around and see if I could do it this weekend.

@pat310
Copy link
Owner

pat310 commented Oct 6, 2016

Awesome, I was thinking I would need to modify the url in src/utils/trendData to add some date parameters. Right now the url that it retrieves trend data from is:
http://www.google.com/trends/fetchComponent?q="${keyword}"&cid=TIMESERIES_GRAPH_0&export=3

But there must be a way to specify date

@ghost
Copy link
Author

ghost commented Oct 6, 2016

So I played with the url request a bit and I've discovered that date specifications are done by adding &date=foo to the url. So in this case it would look like:
http://www.google.com/trends/fetchComponent q="${keyword}"&cid=TIMESERIES_GRAPH_0&export=3&date=foo

For the date options:
Past 30 days: date=today%201-m
Past 7 days: date=now%207-d
Past 24 Hours: date=now%201-d

If you wanna see all options, just go to https://www.google.com/trends/explore?date=now%201-H&q=Apple and change the date dropdown menu and look at how the date value in the url changes.

@ghost
Copy link
Author

ghost commented Oct 11, 2016

So I tried just adding one of the date statements to the url in src/utilities/trendData but it makes the parseJSON() function in src/resources/htmlParser.js throw an error.

@pat310
Copy link
Owner

pat310 commented Oct 14, 2016

Hmm, I'm hoping I will have a chance this weekend to take a look. Sorry for the delay!

@pat310
Copy link
Owner

pat310 commented Oct 22, 2016

@SuttJ Added a timePeriod parameter to trendData - for example:

{keywords: ['michael phelps'], timePeriod: {type: 'hour', value: 5}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant