Closed alexCardazzi closed 2 years ago
Can you make a reproducible example please? So I can copy/paste it.
library("gtrendsR")
#this breaks
gtrends(keyword = c("NBA", "NBA"),
geo = c("US-NY", "US-CA"),
time = c("2010-01-01 2010-01-31", "2011-01-01 2011-01-31")) -> x
#this works
gtrends(keyword = c("NBA", "NBA"),
geo = c("US-NY", "US-CA"),
time = c("all", "all")) -> y
Does it work on the Google Trends website?
Yes. I used a different time period here for demonstration purposes, but both work. Thanks for looking into this.
The problem is here:
Need to use multirange
and not multiline
. Also, locale
should be removed from the constructed URL.
@PMassicotte I'm receiving the same error for this query:
DMA501 <- gtrends(keyword = "wolf", geo = c("US-501"), time = "today+5-y", gprop = c("web"), category = 0, hl = "en-US", low_search_volume = TRUE, cookie_url = "http://trends.google.com/Cookies/NID")$interest_over_time
is it resolved by fixing the problem you've cited?
Problem still not fixed.
I am facing the same error. It is helpful if you could share the measures. Thank you.
The same error has just shown up for me too. I've been running this: g <- gtrends(keyword = "food stamps", geo = "US-MN", time = "today 12-m") for over two years almost daily, and it failed today. I tried some simpler examples from the documentation and they are now failing as well. Thoughts?
A new version (1.5.1) has been uploaded to CRAN. This is fixing it.
Thanks. A new version works!
Awesome! Works for me too. Thanks!
I just started getting this issue 3 days ago after this has been running for 2 years....any suggestion
gd <- gtrends(keyword = "tires", geo = "US", time = "today+5-y", gprop = c("web", "news", "images", "froogle", "youtube"), category = 438, hl = "en-US", low_search_volume = FALSE, cookie_url = "http://trends.google.com/Cookies/NID", tz = 0, onlyInterest = TRUE)
Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:401
Works here. Please update package.
library(gtrendsR)
plot(gtrends(
keyword = "tires", geo = "US", time = "today+5-y",
gprop = c("web", "news", "images", "froogle", "youtube"),
category = 438, hl = "en-US", low_search_volume = FALSE,
cookie_url = "http://trends.google.com/Cookies/NID", tz = 0,
onlyInterest = TRUE
))
Created on 2022-05-27 by the reprex package (v2.0.1)
Along these same lines, I'm trying to do a custom date range where the start date is constant, but the end date resolves to the most recent week of data (hoping to run this every Monday and get the previous week). I tried the below, but get the error: "Cannot parse supplied time format."
Anyone have any tips?
today <- Sys.Date() end <- format(today,format="%Y-%m-%d")
searchRes1 <- gtrendsR::gtrends(keyword = search_terms_trainers, time="2019-01-01 end")
Your code is not right. You assign to a variable end
but then in the string refer to a fixed string "end"
. That is not the same.
Maybe something like ths works:
datestring <- paste("2019-01-01", format(Sys.Date(), "%Y-%m-%d"))
searchRes1 <- gtrendsR::gtrends(keyword = search_terms_trainers, time=datestring)
Your code is not right. You assign to a variable
end
but then in the string refer to a fixed string"end"
. That is not the same.Maybe something like ths works:
datestring <- paste("2019-01-01", format(Sys.Date(), "%Y-%m-%d")) searchRes1 <- gtrendsR::gtrends(keyword = search_terms_trainers, time=datestring)
Thank you. Looks like that will work. Much appreciated
library(gtrendsR) library(tidyverse) trends <- gtrends(keyword = c("python", "R")) Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:429
Same error here ! I'm using v ‘1.5.1’ ... any solution ?
I have been getting the same error when trying to gather data for multiple time frames. It works fine when only pulling data for a single time frame. I am using 1.5.1
Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:401
Any solutions?
Make a reproducible example in R and also link the result you are getting directly on Google Trends website.
https://trends.google.com/trends/explore?date=2019-01-01%202019-10-20&geo=CH&q=svp&hl=en-US
list_keywords <- c("svp", "fdp", "cvp", "sp", "glp")
data.empty2 <- data.frame()
for (i in 1:20) {
for (j in list_keywords) {
x = sample(seq(as.Date('2019-01-01'), as.Date('2019-10-20'), by = "day"), 5)
y = sample(seq(as.Date('2019-01-01'), as.Date('2019-10-20'), by = "day"), 5)
z = ifelse(x > y, paste(y, x, sep = " "),
ifelse(x == y, paste(u, x, sep =" "),
paste(x, y,sep = " ")))
a <- gtrendsR::gtrends(keyword = j,
time = z,
geo = "CH", cookie_url = "http://trends.google.com/Cookies/NID", tz = 0)
b <- a$interest_by_region
data.empty2 <- rbind(data.empty2, b)
tmsleep <- sample(1:10,1)
Sys.sleep(tmsleep)
if(i == 20) break
}
}
I have tried out all the diverse parameter in the gtrends function. The function also runs when inputting a longer list of keywords but only using one time span. Creating a date list outside of the loop and looping through it also does not seem to do the trick. Thank you for your input.
Works very fine with on my side. Also, your link on Google Trends does not include multiple time spans...
library(gtrendsR)
plot(gtrends("svp", geo = "CH", time = "2019-01-01 2019-10-20"))
Created on 2023-05-03 with reprex v2.0.2
I am trying to search a term in different places but for different time periods. While I can input a vector of search terms or places, I cannot seem to use two custom ranges. For example, I want to search "NBA" in 2010-NY and 2011-CA. This is possible in the google trends website, but I keep getting errors with the function. Is there a quick fix?
Error Code: Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:400
Edit: I am using: time = c("2010-01-01 2010-01-31", "2011-01-01 2011-01-31")