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

Error widget$status_code == 200 is not TRUE #166

Closed
yuan-wei-cheng opened this issue Feb 20, 2017 · 41 comments
Closed

Error widget$status_code == 200 is not TRUE #166

yuan-wei-cheng opened this issue Feb 20, 2017 · 41 comments

Comments

@yuan-wei-cheng
Copy link

I tried new version and face this problem after querying like 100 times by for loop
Does this error means I reach the limit quota ?

results <- gtrends("organ meat", geo="US", time="2004-01-01 2004-04-30")$interest_over_time[,2]
Error: widget$status_code == 200 is not TRUE

@PMassicotte
Copy link
Owner

Maybe wait a bit and try again. It is known that Google Trends has a limit. I just dont know the magic number. Can you try in few minutes and let us know.

@yidedereksong
Copy link

yidedereksong commented Jul 1, 2017

Hello Devs, I am looking for your help as I have encountered the same issue. For research purposes I was mass-downloading data using the following codes:
`for(i in 1:134){

for(n in 1:49){
temp <- gtrends(posiecon[i],geo = c("GB"), time = datepara[n])
temp1[(1+((n-1)91)):(n91)] <- paste(temp$interest_over_time$date)
temp2[(1+((n-1)91)):(n91)] <- paste(temp$interest_over_time$hits)
}

posieconrestrends[1:length(temp1),(i2-1):(i2)] <- t(rbind(temp1, temp2))
}`

where I stored the query word and dates as vectors to help with looping. As I had to download daily data, my time span has to be for every three month. After download around 30 of the 134 words, the error message Error: widget$status_code == 200 is not TRUE comes up. My experience is that I had to wait for a day before I can download any data again.

Is there a way to solve for this search volume quota issue? I would be appreciated if you can advise me on this. Thank you!

@PMassicotte
Copy link
Owner

Good question. I have read that the limit if 500 queries per day. Have you try to debug and see what is the error message returned by curl?

@yidedereksong
Copy link

Good question. I have read that the limit if 500 queries per day. Have you try to debug and see what is the error message returned by curl?

I just began to program with R a few month ago, so basically I am a noob in debugging... It seems to me that how Google blocks searches is extremely strange- when I use my phone's hotspot instead of wifi, the quota seemed to be renewed. However, if I use VPN on the computer instead, the quota limit will not be refreshed. Don't know how the mechanism works.

@daeseung1991
Copy link

hi all,

@yidedereksong did u fix your Problem?
I have successfully downloaded the first 100 queries with a for Loop. However, the second for Loop starting from 101 onwards does not work and is displaying me the error Code you are facing with, even though I have manually started the the second for Loop after 24 hours.

@boriya123
Copy link

@yidedereksong could you tell me how to use loop for google trends . mine codes are :

getSeries <- function(a){
out <- NULL
for(i in length(a){
tryCatch({
trend1 <- gtrends(i, geo = "US", time = "2015-01-01 2015-01-31")
trend2 <- gtrends(i, geo = "US", time = "2015-02-01 2015-02-28")
vec <- rbind(as.matrix(trend1),as.matrix(trend2))
out <- cbind(out,vec)
}, error=function(e) {print(e)})
return(out)
Sys.sleep(1)
}

getSeries(out)

a is vector of keywords and got error message of Error: widget$status_code == 200 is not TRUE

@sbenjelloun
Copy link

Hi Philippe,

I have the "res$status_code == 200 is not TRUE" error with your package since 5 days. Every search that I make return me that.

Did you notice a problem with your package ?

Many thanks for your answer !

Sami Benjelloun

@Christianmontes
Copy link

Christianmontes commented Jan 29, 2018

@sbenjelloun look at issue #252, there is a temporary solution. Note that this temporary solution does not give you the related topics and related queries lists.

devtools::install_github('diplodata/gtrendsR')

@harelhan
Copy link

harelhan commented Apr 10, 2018

Hi @PMassicotte

I am getting the same issue. I am working via a VM and am getting the Widget Status ==200 not true error. Below is the code:

check <- gtrends(keyword = "dry", geo = c("CA", "US"), time = "now 7-d",
gprop = c("web"),
category = 0,
hl = "en-US",
low_search_volume = T)

What is interesting is that when I run the same code on my local machine, it works fine. The only difference is that on the VM, I had run a loop multiple times to pull data by each week before I ran the above code. Even that code is also showing same error now. I feel that due to multiple pulls with in a few minutes, Google has blocked the ip of the virtual machine. Do you have any knowledge of any such case? If yes, any help on how to resolve it would be much appreciated.

Thanks
Hitesh

@PMassicotte
Copy link
Owner

@harelhan I am not really sure how Google sets the limits to the number of queries. Maybe others have better experience with batch queries.

@amir-mola
Copy link

amir-mola commented May 28, 2018

@PMassicotte
I am trying to do the example that you provided
gtrends(c("nhl", "nba"), geo = c("CA", "US"))
and it gives me the same error of Error: widget$status_code == 200 is not TRUE eventhough I have the library. Any idea how I can fix this?

@herrmannrobert
Copy link

herrmannrobert commented May 29, 2018

Same error here - might be related to what google says on their website: "We are excited to announce a fresh new redesign of Google Trends! We have added new features and simplified our navigation to make [...]"

@sreuvers
Copy link

sreuvers commented May 29, 2018

Experiencing the same problem since Saturday
Update post:
https://www.blog.google/topics/trends/see-what-world-searching-updated-google-trends/

@fxmb
Copy link

fxmb commented May 29, 2018

Error: widget$status_code == 200 is not TRUE

I am experiencing the same Problem since yesterday. Script worked totally fine before that... Any help is highly appreciated.

@bbakk14
Copy link

bbakk14 commented May 29, 2018

Having the same problem: Error: widget$status_code == 200 is not TRUE after being able to run things smoothly a few days ago.

Tried reinstalling curl and then the dev version but still not working.

@rpl15
Copy link

rpl15 commented May 30, 2018

I am also experiencing the same problem for 4 days now. I have tried reinstalling curl and then the dev version, but still getting the Error: widget$status_code == 200. Any suggestions?

@eddelbuettel
Copy link
Collaborator

See #273 and #274

@gafap
Copy link

gafap commented Aug 9, 2020

Dear all,
I'm having a similar problem. I'm trying to retrieve some searches for the different regions of Spain. However, for some of them, it won't work. For example, if I do it for Madrid

pull_orig <- gtrends("casa", time=date_range, geo="ES-MD")

I get the error
Error: Country code not valid. Please use 'data(countries)' to retreive valid codes.

I have checked then in R the gtrends, what are the codes using
geo.codes = sort(unique(countries[substr(countries$sub_code, 1, 2) == "ES", ]$sub_code))

It seems that the code for madrid is "ES-M". However, when I use that,
pull_orig <- gtrends("casa", time=date_range, geo="ES-M")

I get the error
Error in get_widget(comparison_item, category, gprop, hl, cookie_url, :
widget$status_code == 200 is not TRUE

More interestingly, if I do the search directly in google trends, the URL uses "ES-MD" as the code for MAdrid, and it works fine. Try
https://trends.google.com/trends/explore?date=today%205-y&geo=ES-MD&q=casa

Any suggestions? Much appreciate the help!
THanks,
Gabriel

@PMassicotte
Copy link
Owner

It must be because ES-M is the entry we have in the data source we used to validate the country codes.

@gafap
Copy link

gafap commented Aug 9, 2020

Thanks @PMassicotte , is there a way to fix the error? and retrieve the data for Madrid through gtrends?

@PMassicotte
Copy link
Owner

Ideally, we should have a list of all Google country codes. If we can find that, we can use it as a source to populate the "countries" data.frame of the package.

@gafap
Copy link

gafap commented Aug 10, 2020

Sounds good @PMassicotte . I have downloaded below all the codes for the "regions" of Spain (the only subnational level allowed for trends for Spain). These were obtained from the wikipedia page for Spain (https://en.wikipedia.org/wiki/ISO_3166-2:ES). I have tested them using the googletrends site and they all work well. There's only 7 regions with the wrong code right now, the rest are ok.
Would it be possible to update the gtrends command with these codes for Spain?
Thanks in advance!

name,geo
Andalucia,ES-AN
Aragon,ES-AR
Principado de Asturias,ES-AS
Canarias,ES-CN
Cantabria,ES-CB
Castilla-La Mancha,ES-CM
Castilla y Leon,ES-CL
Catalunya,ES-CT
Extremadura,ES-EX
Galicia,ES-GA
Illes Balears,ES-IB
La Rioja,ES-RI
Comunidad de Madrid ,ES-MD
Region de Murcia,ES-MC
Comunidad Foral de Navarra,ES-NC
Pais Vasco,ES-PV
Comunidad Valenciana,ES-VC

@PMassicotte
Copy link
Owner

I found a way to get more codes programmatically. I will work on that this week when I have few minutes.

PMassicotte added a commit that referenced this issue Aug 20, 2020
@gafap
Copy link

gafap commented Sep 2, 2020

Dear @PMassicotte , did you have any luck with updating the country codes? I still have problems with the Spanish provinces. Can I help with that somehow? thanks again!

@PMassicotte
Copy link
Owner

Install the dev version.

@gafap
Copy link

gafap commented Sep 6, 2020

@PMassicotte awesome! works great, thanks!

@Easygamer01s
Copy link

Hi all !

Did have the same problem : "error-widgetstatus-code-200-is-not-true" -> it said too many request at a time when using RCurl on a link.

I added Sys.sleep(15) between each request, but it wasn't sufficient. Then, I downloaded a VPN and it seems to work now.. I guess I will have to change the VPN connection every 200 demands..

@alfredo-lefranc
Copy link

Dear @PMassicotte, I ran into the same problem with regions in Mexico. Only states appear to be available options now from what I can see here. Therefore, only a subset of the sub_codes in Mexico will work. The code below does work for me.

regions <-gtrendsR::countries%>%
filter(country_code=="MX")
regions<-regions[c(1:29,31,32,33),]

for (j in 1:length(regions$sub_code)){

naptime(1)

rk<-gtrends(c("term1", "term2"),
gprop = "web",
geo=regions$sub_code[j],
category = 0,
time ="2010-01-01 2020-01-01")
}

I used the devtools version of the package to run this test.

@PMassicotte
Copy link
Owner

Do not use regions$sub_code but provide your own code. If the provided code is valid, your query will work.

@Jgeraldo5
Copy link

Hello, @PMassicotte . I'm starting my data research career in medical school here in Brazil and would really like to use the features of the "gtrends" function in some time series models. However, I cannot extract the data by city, which would be very valuable for my future research. I saw that it is possible to use this feature for cities in the United States, but I cannot do the same for cities in my country. Is there any way to do this? Thank you in advance for your attention and your great contribution to science.

@PMassicotte
Copy link
Owner

Can you do it on the Googe Trens website?

@Jgeraldo5
Copy link

Not. On the Google trends website, I can only do this search by state, but not by cities. However, city data appears in the "Interests by City" tab, but I don't know how to extract this time-distributed data.

@PMassicotte
Copy link
Owner

PMassicotte commented Nov 20, 2022

Please show an example from the Google website. #437

@Jgeraldo5
Copy link

When searching for the term "world cup" on google trends, I can filter the search by state (ceará), but not by city. However, I can see some city names where the term is most searched in the "Interests by city" section. See the link:

https://trends.google.com.br/trends/explore?date=all&geo=BR-CE&q=copa%20do%20mundo

Is there a way to get temporal data from searches by city using the "gtrends" function?

@PMassicotte
Copy link
Owner

The link is not working.

@Jgeraldo5
Copy link

@PMassicotte
Copy link
Owner

This works fine:

r$> gtrends("Brazil", geo = "BR-CE")$interest_by_city
                  location hits keyword   geo gprop
1       Jericoacoara Beach  100  Brazil BR-CE   web
2                  Aquiraz   26  Brazil BR-CE   web
3                   Sobral   24  Brazil BR-CE   web
4               Maranguape   23  Brazil BR-CE   web
5                  Aracati   23  Brazil BR-CE   web
6                 Paracuru   23  Brazil BR-CE   web
7                   Russas   22  Brazil BR-CE   web
8                Fortaleza   22  Brazil BR-CE   web
9                  Caucaia   22  Brazil BR-CE   web
10                 Eusébio   22  Brazil BR-CE   web
11                  Acaraú   21  Brazil BR-CE   web
12                Pacatuba   21  Brazil BR-CE   web
13            São Benedito   20  Brazil BR-CE   web
14                 Pacajus   20  Brazil BR-CE   web
15                Cascavel   19  Brazil BR-CE   web
16                 Quixadá   18  Brazil BR-CE   web
17                Barbalha   17  Brazil BR-CE   web
18                 Tianguá   17  Brazil BR-CE   web
19               Horizonte   16  Brazil BR-CE   web
20               Maracanaú   16  Brazil BR-CE   web
21       Juazeiro do Norte   15  Brazil BR-CE   web
22                   Crato   15  Brazil BR-CE   web
23       Limoeiro do Norte   15  Brazil BR-CE   web
24                     Icó   15  Brazil BR-CE   web
25                 Camocim   15  Brazil BR-CE   web
26                 Canindé   14  Brazil BR-CE   web
27                 Crateús   14  Brazil BR-CE   web
28            Quixeramobim   NA  Brazil BR-CE   web
29                  Iguatu   NA  Brazil BR-CE   web
30                 Deserto   NA  Brazil BR-CE   web
31               Aprazível   NA  Brazil BR-CE   web
32           Port of Pecem   NA  Brazil BR-CE   web
33                  Trairi   NA  Brazil BR-CE   web
34                   Barro   NA  Brazil BR-CE   web
35                  Tapuio   NA  Brazil BR-CE   web
36                  Aurora   NA  Brazil BR-CE   web
37            Sítio Alegre   NA  Brazil BR-CE   web
38              Jaguaruana   NA  Brazil BR-CE   web
39           Independência   NA  Brazil BR-CE   web
40                Baturité   NA  Brazil BR-CE   web
41 São Gonçalo do Amarante   NA  Brazil BR-CE   web
42               Itaitinga   NA  Brazil BR-CE   web
43            Missão Velha   NA  Brazil BR-CE   web
44                 Currais   NA  Brazil BR-CE   web
45                    Tauá   NA  Brazil BR-CE   web
46         Viçosa do Ceará   NA  Brazil BR-CE   web
47     Guaraciaba do Norte   NA  Brazil BR-CE   web
48                 Mauriti   NA  Brazil BR-CE   web
49             Majorlândia   NA  Brazil BR-CE   web
50                Beberibe   NA  Brazil BR-CE   web
51                Ibiapina   NA  Brazil BR-CE   web
52            Pedra Branca   NA  Brazil BR-CE   web
53               Itapipoca   NA  Brazil BR-CE   web
54            Campos Sales   NA  Brazil BR-CE   web
55                     Ipu   NA  Brazil BR-CE   web
56                Brejinho   NA  Brazil BR-CE   web
57          Santa Quitéria   NA  Brazil BR-CE   web
58              Pentecoste   NA  Brazil BR-CE   web
59                Milagres   NA  Brazil BR-CE   web
60                 Itapagé   NA  Brazil BR-CE   web
61                  Icapuí   NA  Brazil BR-CE   web
62                Irauçuba   NA  Brazil BR-CE   web
63               Jaguaribe   NA  Brazil BR-CE   web
64              Boa Viagem   NA  Brazil BR-CE   web
65                 Guajiru   NA  Brazil BR-CE   web
66                Quitaiús   NA  Brazil BR-CE   web
67   Vila Passagem Florida   NA  Brazil BR-CE   web
``

@Jgeraldo5
Copy link

Thanks! But what I liked was getting the search data for the term “Brazil” in a period from 2011 to 2022 for a specific city in the country like the city of "Barbalha", for example. Is it possible to do that?

@PMassicotte
Copy link
Owner

Is it possible to do it on Google Trends website?

@Jgeraldo5
Copy link

I think not

@PMassicotte
Copy link
Owner

If it is not possible on the official web site, you can not do it in gtrendsR

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

No branches or pull requests