PMassicotte / gtrendsR

R functions to perform and display Google Trends queries
352 stars 112 forks source link

Status code was not 200. Returned status code:500 #451

Open jdeverdun opened 1 year ago

jdeverdun commented 1 year ago

Hello everyone,

Since a few day I've got the error (on any request): Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:500

I first though it was a daily limit, yet I still havethis issue on other computer. Am I the only one ?

EDIT : the issue seems to be related to the time range, it fails when I give for example a=gtrends( 'bike' , geo = 'FR' ,time= 'now 1-d' , low_search_volume = TRUE)

but it "does not fail" when date range is specified.

I guess it is related to google trends itself, but wanted to make sure !

Thanks for your help.

Best regards

lukschue commented 1 year ago

Hello jdeverdun,

You are not the only one. I gather Google Trends data automatically on a daily basis for a project and since today I got the same Error code for all my request. Though until yesterday it still seemed to work out for me.

And also when the range is specified it does still work.

I hope this problem is solvable.

Kind regards.

PMassicotte commented 1 year ago

I am also getting the error, but only for the "past day" search. I will investigate this.

jdeverdun commented 1 year ago

Just to let you know I tried various tools, like pytrends and even serpAPI but same, I guess google is doing some work

shrikant2002 commented 1 year ago

same happening with me since 3 days

ccharisis commented 1 year ago

Same issue for me. Started yesterday.

ccharisis commented 1 year ago

I am also getting the error, but only for the "past day" search. I will investigate this.

Hi! Do you have any update on the issue? I am still getting the same error when I use "now" time formats like "now 1-H" or "now 1-d" etc. The other time formats like 'today 1-m' seem to work fine. So it looks like an issue that affects only the "Last" n hours /days and not the "Past" queries. Please let me know if you have any updates on the problem.

xritzim commented 1 year ago

Hello, I'm experiencing the same issue. I get the status code 500.

PMassicotte commented 1 year ago

This is what we are sending:

{
  "userConfig": {
    "userType": "USER_TYPE_SCRAPER"
  },
  "locale": "en-US",
  "comparisonItem": [
    {
      "geo": {
        "country": "FR"
      },
      "complexKeywordsRestriction": {
        "keyword": [
          {
            "type": "BROAD",
            "value": "bike"
          }
        ]
      }
    }
  ],
  "resolution": "EIGHT_MINUTE",
  "requestOptions": {
    "category": 0,
    "backend": "CM",
    "property": ""
  },
  "time": "2023-07-04T12\\:03\\:43 2023-07-05T12\\:03\\:43"
}

This is what Google Trends (website) is sending:

{
  "time": "2023-07-04T11\\:36\\:47 2023-07-05T11\\:36\\:47",
  "resolution": "EIGHT_MINUTE",
  "locale": "en-US",
  "comparisonItem": [
    {
      "geo": {
        "country": "FR"
      },
      "complexKeywordsRestriction": {
        "keyword": [
          {
            "type": "BROAD",
            "value": "bike"
          }
        ]
      }
    }
  ],
  "requestOptions": {
    "property": "",
    "backend": "CM",
    "category": 0
  },
  "userConfig": {
    "userType": "USER_TYPE_LEGIT_USER"
  }
}

Besides userType, this is the same. So I do not know what is going on at the moment. Note that userType is also set to USER_TYPE_SCRAPER when we use other time ranges such as date=today 5-y so this is not obvious that this is the cause of the problem.

jdeverdun commented 1 year ago

Thanks for this information, I also checked on the google trends website and in fact we can see that if you try to access the embed code for the interest by city map, we also have a 505 error for this kind of request (still working fine for specific date request).

So again, google should be working on it.

Best

PMassicotte commented 1 year ago

I will keep an eye open for this.

ccharisis commented 1 year ago

I will keep an eye open for this.

Thank you.

Helldez commented 12 months ago

Hi, does anyone have any updates on this? It seems to be a Google Trends issue, but does anyone know if it's transient or we need to find another way to fetch the weekly and daily data?

JBleher commented 12 months ago

I tried to enhance the request by adding the part: "userConfig": { "userType": "USER_TYPE_LEGIT_USER" }

However, then I get a HTML-401 error. I guess one needs to send a cookie or something with the request for the widget to the get the status USER_TYPE_LEGIT_USER.

PMassicotte commented 12 months ago

I do not see an easy fix at the moment. Any ideas are welcome :)

Helldez commented 12 months ago

I'm not a technician but could it be due to these errors on the google trends website? image

ccharisis commented 11 months ago

I just noticed that the response changed from 500 (Internal Server Error) to 429 (Too many requests) .

Draptol commented 11 months ago

yeah in node.js lib I have the same problem. 500 http is replaced by 429 even if I use residential proxies.

MattCowgill commented 11 months ago

Long time {gtrendsR} user here, now encountering this same problem for the first time :(

Helldez commented 11 months ago

Same here, it has been going on for three weeks

barbara1998 commented 11 months ago

EDIT: We have a scheduler running to gather google trends data automatically on a daily basis, using now 1-d. This has not worked for the last 3 weeks, but since July 22, 5 am in the morning, it produced datasets again. But now when I run the script manually, it returns the "Status code was not 200. Returned status code:429" error code.

PMassicotte commented 11 months ago

@barbara1998 You are able to use now 1-d ?

barbara1998 commented 11 months ago

@PMassicotte sorry, maybe a false alarm, I made an edit to my comment.

PMassicotte commented 11 months ago

Tx for reporting.

janinepdasilva commented 11 months ago

I'm having the same issue.

xritzim commented 11 months ago

Hello all!! It seems it works now!!

ccharisis commented 11 months ago

I confirm, the API is functional!

PMassicotte commented 11 months ago

Oh good to know! Anyone has information on what happened?

lukschue commented 10 months ago

Hey everyone,

as I also mentioned in #452 I run several gtrendsR request automatically on a daily basis. Since the 16.08.2023 the problem from the 04.07. seems to repeat itself. Since then there is no new data.

danielasilver commented 9 months ago

Encountering this issue today for the first time:

gtrends("Biden", gprop = 'web', geo = 'US',time = "2023-02-15 2023-04-14" ) Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:429

Tried various time ranges, got same result, except for on the second try, which worked:

gtrends("Biden", gprop = 'web',geo = 'US', time = "now 1-d" )

The first attempt with the above code resulted in:

Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:500

PMassicotte commented 9 months ago

Not sure what is going on, working on my side:

library(gtrendsR)
plot(gtrends("Biden", gprop = 'web', geo = 'US',time = "2023-02-15 2023-04-14" ))

Created on 2023-10-13 with reprex v2.0.2

danielasilver commented 9 months ago

thank you. not sure what is going on. this works: plot(gtrends("Biden", gprop = 'web', geo = 'US',time = "2023-02-15 2023-04-14" ))

but this does not:

plot(gtrends("Biden", gprop = 'web', geo = 'US',time = "all" )) Error in FUN(X[[i]], ...) : Status code was not 200. Returned status code:429

Nor does this:

plot(gtrends("Biden", gprop = 'web', geo = 'US',time = "today 3-m" )) Error in FUN(X[[i]], ...) : Status code was not 200. Returned status code:429

Nor does this, my real interest:

place2 <- gtrends(keyword = c("/m/0c3kw5"), geo = "", time="all", low_search_volume = F) Error in FUN(X[[i]], ...) : Status code was not 200. Returned status code:429

waynelapierre commented 8 months ago

I also encountered this issue:

gtrends("nuclear war", geo = "US", gprop = "web")
Error in FUN(X[[i]], ...) : 
  Status code was not 200. Returned status code:429
DataSocialist commented 8 months ago

I encounter the same problem since today.

gtrends(keyword = "svp",time = "now 1-d", geo = "CH",cookie_url = "http://trends.google.com/Cookies/NID", tz=Sys.timezone()) Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:429Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:429

jdeverdun commented 8 months ago

yep same here, on few request are accepted.

Helldez commented 8 months ago

Same here

eddelbuettel commented 8 months ago

It is failing for me too, on two machines including one with a rebuilt-from-git installation, and as an additional check also in a fresh Docker run (i.e. no possible stale cookie).

jdeverdun commented 7 months ago

Anyone has any updates ?

JBleher commented 7 months ago

the widget now contains the line: "userConfig":{"userType":"USER_TYPE_SCRAPER"} the google request sends: "userConfig":{"userType":"USER_TYPE_LEGIT_USER"}

This might be what is causing the problem...

PMassicotte commented 7 months ago

https://github.com/PMassicotte/gtrendsR/issues/440#issuecomment-1339273755

jdeverdun commented 7 months ago

Just saw that embed trends were working again. I was hoping something was unlocked 😭

PMassicotte commented 7 months ago

Just tried to force using

  payload2$userConfig$userType <- "USER_TYPE_LEGIT_USER"

No success, this will require more investigation.

pensivedog commented 6 months ago

Still not working in 2024:

Error in interest_over_time(widget, comparison_item, tz) : 
  Status code was not 200. Returned status code:429

Anyone find a solution?

jdeverdun commented 6 months ago

In fact it was working back a few days ago, but the issue came back yesterday for everyone

BigTimeStats commented 4 months ago

Same issue for me this week -- does not work no matter the keyword or delay.

Is there any way to refresh the cookies? It seemed like a package reinstall fixed the issue, at least temporarily for a few test runs

EDIT: not working again even after reinstall.

ytmben commented 3 months ago

Same issue for me, tried to run K0 <- gtrends(keyword = term, geo = country, time = period, onlyInterest = TRUE) and received the same error: Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:429

PMassicotte commented 3 months ago

Please make a reproducible example. This gtrends("nhl") is working on my side.

ytmben commented 3 months ago

term = c("Mediterranean diet", "Veganism", "Vegetarianism", "Gluten-free diet", "Low-carbohydrate diet") country = "" period = "2010-01-01 2023-12-31" K0 <- gtrends(keyword = term, geo = country, time = period, onlyInterest = TRUE)

PMassicotte commented 3 months ago

Works fine on my side.

library(gtrendsR)

term <- c("Mediterranean diet", "Veganism", "Vegetarianism", "Gluten-free diet", "Low-carbohydrate diet")
country <- ""
period <- "2010-01-01 2023-12-31"
K0 <- gtrends(keyword = term, geo = country, time = period, onlyInterest = TRUE)

plot(K0)

Created on 2024-03-15 with reprex v2.1.0

Mettez14 commented 3 months ago

Works fine on my side.

library(gtrendsR)

term <- c("Mediterranean diet", "Veganism", "Vegetarianism", "Gluten-free diet", "Low-carbohydrate diet")
country <- ""
period <- "2010-01-01 2023-12-31"
K0 <- gtrends(keyword = term, geo = country, time = period, onlyInterest = TRUE)

plot(K0)

Created on 2024-03-15 with reprex v2.1.0

Your specific example also produces the error for me:

term <- c("Mediterranean diet", "Veganism", "Vegetarianism", "Gluten-free diet", "Low-carbohydrate diet") country <- "" period <- "2010-01-01 2023-12-31" K0 <- gtrends(keyword = term, geo = country, time = period, onlyInterest = TRUE) Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:429

ytmben commented 3 months ago

Now my previous example works oddly enough, but I am having trouble with the exact next line of code: K1 <- gtrends(keyword = term[1], geo = country, time = period, onlyInterest = TRUE) It again returns the same error Edit: I just re-tried it, now it works