-
Notifications
You must be signed in to change notification settings - Fork 112
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
Google Trends changes (error 200) #273
Comments
I got it to work. Do this: h <- new_handle() Then, modify get_widget like so: (widget <- curl::curl_fetch_memory(url,h)) I got status 200, and then was able to use that to extract the data. |
@zachokeeffe would you mind explaining the get_widget part a bit further? What is supposed to go in the url variable? |
@SaulCes in zzz.R (https://github.com/PMassicotte/gtrendsR/blob/master/R/zzz.R), get_widget is defined. It is the first thing that requests info from Google, before grabbing actual trend data (which it requires a token for). While other functions (interest_over_time, interest_by_region) also use curl::curl_fetch_memory(), you only need to specify the cookie handler, h, in the curl_getch_memory() call in get_widget(). You would change the line (74) from:
to
And you only need to get the cookie once in the session; then you can repeatedly use that handler. So, you could, e.g., have a function like "get_api_cookies()" that the user has to run once, or, probably better for users, you could have an if() statement in get_widget that checks to make sure the handler is available, and if it is not, create it, and then proceed. |
@zachokeeffe Mind to create a PR? |
@zachokeeffe thanks so much - working well! |
Thanks a lot @zachokeeffe - performs like new... |
so, how do we implement the change? im not sure how to edit that line. any easy way to install from your repo? |
@Christianmontes Just sit back and watch #274 |
Sorry if I shouldn't be asking here but would anyone be able to tell me how to swap (am an R novice) "http://trends.google.com/Cookies/NID" into
in my own installation of the package? I am behind a firewall that blocks social media sites like Google Plus which seems somehow connected to the OTZ cookie and throws an error. It appears that the NID cookie would work when running
outside of the package. |
@bbakk14 Interesting. That's good to know. Try installing my fork to see if the alternative link works for you. If it does, we should probably adopt it as the default. In a new session try, library(devtools) Does that work? |
@zachokeeffe It works!! Thanks for the solution and quick response. |
@zachokeeffe Unfortunately, it looks like the NID cookie has stopped working for me as well (connection timing out). It doesn't seem that this is related to Google+ at all this time though. Would you potentially have any other tips? |
@bbakk14 Are you still having this issue? Does it occur in a fresh R environment? If so, could you please provide the exact error message? |
@zachokeeffe Thanks for taking a look. I get the following error when using gtrends() in a fresh R environment
I also get the time out error when calling curl_fetch_memory seperately
I don't know if it helps but the following is produced by GET()
|
@bbakk14 Have you tried setting a higher timeout threshold? E.g., before running it, try: options(timeout= 4000000) |
@zachokeeffe Still having the same issue. Entered options(timeout= 4000000) but still reach a timeout after 10015 milliseconds. It looks like @klarioui has had the same issue as well. |
@bbakk14 I do have the same error and tried changing the timeout option to no avail... Seems the problem is related to my server, still looking into it. |
@klarioui same on my side, please keep us posted if you have any breakthroughs |
@zachokeeffe Thanks a lot for providing this fix! |
GeneralMills/pytrends#243 (comment)
Hint: https://cran.r-project.org/web/packages/curl/vignettes/intro.html#reading_cookies
The text was updated successfully, but these errors were encountered: