Git Product home page Git Product logo

gogtrends's People

Contributors

groovili avatar haghft avatar jannik-baar avatar math-88 avatar perriea avatar spennymac avatar ycd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gogtrends's Issues

Still getting Too Many Requests

Hi!
Thanks for the lib.
I found out that you already handled this case

if resp.StatusCode == http.StatusTooManyRequests {

But i'm still getting 429
Any thoughts?
Code is very simple and like you did it in examples

        keyword = r.URL.Query().Get("keyword")

	ctx := context.Background()

	gogtrends.Debug(true)

	explore, trendsReqError := gogtrends.Explore(ctx, &gogtrends.ExploreRequest{
		ComparisonItems: []*gogtrends.ComparisonItem{
			{
				Keyword: keyword,
				Geo:     "",
				Time:    "today 12-m",
			},
		},
		Category: 31,
		Property: "",
	}, "EN")

	handleError(trendsReqError, "trendsReqError")

	overTime, interestOverTimeError := gogtrends.InterestOverTime(ctx, explore[0], "EN")

	handleError(interestOverTimeError, "interestOverTimeError failed")

	res, marshalError := json.Marshal(overTime)

	handleError(marshalError, "marshal error")

image

How the Time works?

In the example provided Time is filled as:
Keyword: "Go", Geo: "US", Time: "today+12-m",

But I'm not sure how to use any other time other than this one. Could someone give an explanation about the pattern?

Data race

==================
WARNING: DATA RACE
Read at 0x00c00018f230 by goroutine 34:
  runtime.mapaccess1_faststr()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/map_faststr.go:12 +0x0
  net/http.http2isConnectionCloseRequest()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:9081 +0x1da
  net/http.(*http2clientConnReadLoop).endStreamError()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:8715 +0x6a
  net/http.(*http2clientConnReadLoop).endStream()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:8706 +0x206
  net/http.(*http2clientConnReadLoop).processData()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:8696 +0x1e0
  net/http.(*http2clientConnReadLoop).run()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:8281 +0x5bc
  net/http.(*http2ClientConn).readLoop()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:8174 +0xb6

Previous write at 0x00c00018f230 by main goroutine:
  runtime.mapassign_faststr()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/map_faststr.go:202 +0x0
  net/textproto.MIMEHeader.Set()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/textproto/header.go:22 +0x88a
  net/http.Header.Set()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/header.go:37 +0x7d1
  github.com/groovili/gogtrends.(*gClient).do()
      /Users/lucas.loeffel/go/pkg/mod/github.com/groovili/[email protected]/client.go:77 +0x77f
  github.com/groovili/gogtrends.Explore()
      /Users/lucas.loeffel/go/pkg/mod/github.com/groovili/[email protected]/gogtrends.go:148 +0x5aa
  github.com/twys-software-gmbh/bitmachine/trend/google.(*Google).getExploreWidgets()
      /Users/lucas.loeffel/go/src/github.com/twys-software-gmbh/bitmachine/trend/google/google.go:32 +0x25b
  github.com/twys-software-gmbh/bitmachine/trend/google.(*Google).GetValue()
      /Users/lucas.loeffel/go/src/github.com/twys-software-gmbh/bitmachine/trend/google/value.go:13 +0xb4
  github.com/twys-software-gmbh/bitmachine/bitmachine.(*Bitmachine).Preload()
      /Users/lucas.loeffel/go/src/github.com/twys-software-gmbh/bitmachine/bitmachine/preload.go:18 +0xee
  github.com/twys-software-gmbh/bitmachine/bitmachine.(*Bitmachine).Run()
      /Users/lucas.loeffel/go/src/github.com/twys-software-gmbh/bitmachine/bitmachine/run.go:17 +0xed
  main.main()
      /Users/lucas.loeffel/go/src/github.com/twys-software-gmbh/bitmachine/main.go:82 +0xde6

Goroutine 34 (running) created at:
  net/http.(*http2Transport).newClientConn()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:7174 +0xbc3
  net/http.(*http2Transport).NewClientConn()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:7107 +0x79
  net/http.(*http2addConnCall).run()
      /usr/local/Cellar/go/1.14.2_1/libexec/src/net/http/h2_bundle.go:865 +0x55
==================

error when searching non ASCII keywords

When searching non ASCII keywords like "résumé", "anunciação" or "반갑습니다" we get the error:

request data: code = 401, status = 401 Unauthorized

By digging a lilttle bit I found out that the issue is related to how the response body from requests is handle. It seems to replace all non ASCII characters with an error rune which causes it to crash as Google API can't handle the keyword anymore.

an example of a response body with error after using the keywords "fantástico":

map[examples:[] keywords:[map[keyword:fant��stico name:fant��stico type:Termo de pesquisa]] shareText:Veja o interesse de pesquisa sobre fant��stico por horário, local e popularidade no Google Trends shouldShowMultiHeatMapMessage:false timeRanges:[01/01/2004 – 29/08/2019] widgets:[map[bullets:[map[text:fant��stico]] embedTemplate:fe_embed helpDialog:map[content:Os números representam o interesse de pesquisa relativo ao ponto mais alto no gráfico de uma determinada região em um dado período. Um valor de 100 representa o pico de popularidade de um termo. Um valor de 50 significa que o termo teve metade da popularidade. Uma pontuação de 0 significa que não havia dados suficientes sobre o termo. title:Interesse ao longo do tempo] id:TIMESERIES isCurated:false isLong:true lineAnnotationText:Interesse de pesquisa request:map[comparisonItem:[map[complexKeywordsRestriction:map[keyword:[map[type:BROAD value:fant��stico]]] geo:map[country:BR]]] locale:pt-BR requestOptions:map[backend:IZG category:0 property:] resolution:MONTH time:2004-01-01 2019-08-29] showAverages:false showLegend:false template:fe title:Interesse ao longo do tempo token:APP6_UEAAAAAXW6MKHVaN49f_nO0AkwnF3SSDPhXzYCA type:fe_line_chart version:1] map[bullet:fant��stico color:PALETTE_COLOR_1 displayMode:regions embedTemplate:fe_embed geo:BR helpDialog:map[content:Veja em que local seu termo foi mais famoso durante um período específico. Os valores são calculados em uma escala de 0 a 100, em que 100 é o local com a maior popularidade como uma fração do total de pesquisas naquele local; 50 indica um local que tem metade da popularidade; e 0 indica um local em que não houve dados suficientes para o termo.

Observação: um valor maior significa uma proporção maior de consultas, não uma contagem absoluta maior. Um pequeno país em que 80% das consultas são sobre "bananas" terá duas vezes a pontuação de um grande país em que somente 40% das consultas são sobre esse termo. title:Interesse por sub-região url:https://support.google.com/trends/answer/4355212] id:GEO_MAP index:0 isCurated:false isLong:true request:map[comparisonItem:[map[complexKeywordsRestriction:map[keyword:[map[type:BROAD value:fant��stico]]] time:2004-01-01 2019-08-29]] geo:map[country:BR] locale:pt-BR requestOptions:map[backend:IZG category:0 property:] resolution:REGION] resolution:provinces searchInterestLabel:Interesse de pesquisa template:fe title:Interesse por sub-região token:APP6_UEAAAAAXW6MKL5D01rApYSlBPCKGOFMUC44LZVK type:fe_geo_chart_explore version:1] map[color:PALETTE_COLOR_1 embedTemplate:fe_embed helpDialog:map[content:Os usuários que pesquisaram pelo seu termo também pesquisaram por estes assuntos. Veja pelas seguintes métricas:

* Principais: os assuntos mais pesquisados. A pontuação está em uma escala relativa, em que 100 é o assunto mais pesquisado; 50 é o assunto pesquisado com metade dessa frequência etc.

* Em ascensão: os assuntos relacionados ao maior aumento na frequência de pesquisa desde o período anterior. Os resultados marcados como "Aumento repentino" tiveram um aumento muito relevante, provavelmente devido ao fato de que esses assuntos são novos e tiveram nenhuma ou poucas pesquisas anteriores. title:Assuntos relacionados] id:RELATED_TOPICS isCurated:false isLong:false keywordName:fant��stico request:map[keywordType:ENTITY language:pt metric:[TOP RISING] requestOptions:map[backend:IZG category:0 property:] restriction:map[complexKeywordsRestriction:map[keyword:[map[type:BROAD value:fant��stico]]] geo:map[country:BR] originalTimeRangeForExploreUrl:2004-01-01 2019-08-29 time:2004-01-01 2019-08-29] trendinessSettings:map[compareTime:2004-01-01 2005-01-01]] template:fe title:Assuntos relacionados token:APP6_UEAAAAAXW6MKO_yG13GnFZMPUX4It9eq8ez-X2n type:fe_related_searches version:1] map[color:PALETTE_COLOR_1 embedTemplate:fe_embed helpDialog:map[content:Os usuários que pesquisaram pelo seu termo também fizeram estas consultas. Veja pelas seguintes métricas:

* Principais: consultas mais frequentes. A pontuação está em uma escala relativa, em que 100 é a consulta mais pesquisada; 50 é a consulta feita com metade dessa frequência etc.

* Em ascensão: consultas com o maior aumento na frequência de pesquisa desde o período anterior. Resultados marcados com "Aumento repentino" tiveram um aumento muito relevante, provavelmente devido a consultas novas que tiveram nenhuma ou poucas pesquisas anteriores. title:Consultas relacionadas url:https://support.google.com/trends/answer/4355000] id:RELATED_QUERIES isCurated:false isLong:false keywordName:fant��stico request:map[keywordType:QUERY language:pt metric:[TOP RISING] requestOptions:map[backend:IZG category:0 property:] restriction:map[complexKeywordsRestriction:map[keyword:[map[type:BROAD value:fant��stico]]] geo:map[country:BR] originalTimeRangeForExploreUrl:2004-01-01 2019-08-29 time:2004-01-01 2019-08-29] trendinessSettings:map[compareTime:2004-01-01 2005-01-01]] template:fe title:Consultas relacionadas token:APP6_UEAAAAAXW6MKPROM43760lgZ5e1iFVYiIju2Lyf type:fe_related_searches version:1]]]

UPDATE
I did some functions to find the keywords with error and chance them in place to re correct ones. The returned JSON seemed to be the expected, however when passing the decoded struct returned from the Explore function to any of the other Widget functions I couldn't get any valid response.

A response from using Related:

{"default":{"rankedList":[{"rankedKeyword":[]},{"rankedKeyword":[]}]}}

Empty Keyword search

The empty keyword search for explores does not work. It causes a 400 Bad Request.
My guess is the keyword should be omitted if it is empty, but this does not happen.

[Debug] Response: 429 Too Many Requests

Hi
How can i avoid this error, everytime i try to recover data i find this error:

[Debug] Response: &{429 Too Many Requests 429 HTTP/2.0 2 0 map[Alt-Svc:[h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"] Cache-Control:[no-cache, no-store, max-age=0, must-revalidate] Content-Security-Policy:[script-src 'nonce-MbgHlkCAIUd6Dor2BMruvw' 'unsafe-inline' 'strict-dynamic' https: http: 'unsafe-eval';object-src 'none';base-uri 'self';report-uri /trends/cspreport] Content-Type:[text/html; charset=utf-8] Cross-Origin-Opener-Policy:[same-origin-allow-popups] Date:[Tue, 22 Nov 2022 15:21:38 GMT] Expires:[Mon, 01 Jan 1990 00:00:00 GMT] P3p:[CP="This is not a P3P policy! See g.co/p3phelp for more info."] Pragma:[no-cache] Server:[GSE] Set-Cookie:[NID=511=UBRQU8IhfIWTbiMogok59t01CWb16d3vqnvj0QiLL-i9ywC6SYQC63PfHT7s2DutzzVD7ZUOmSgwjbPVGK1vVDZVWHkwqUKNXPliOjD3Soee6DX7NsggLvPxYfuEBKk1tB9sjvrZDX1P9JS0jdQRkhLsHhizsbGlZA6V6U50kkc; expires=Wed, 24-May-2023 15:21:38 GMT; path=/; domain=.google.com; HttpOnly] X-Content-Type-Options:[nosniff] X-Frame-Options:[SAMEORIGIN] X-Xss-Protection:[1; mode=block]] 0xc0000a9350 -1 [] false true map[] 0xc0001a4000 0xc0003020b0}

thanks

401 for related queries

It worked well until yesterday, but today it gives this error for related queries
request data: code = 401, status = 401 Unauthorized: failed to perform http request

No place to set proxy

there are not any params to set proxy for http requests. this will make the crawler been blocked by google.

401 if geo not set

Hey,

I getting an 401 error when i try to set geo to "" - also without geo is not working.

ctx := context.Background()
	explore, err := gogtrends.Explore(ctx,
		&gogtrends.ExploreRequest{
			ComparisonItems: []*gogtrends.ComparisonItem{
				{
					Keyword: "Apple",
					Time:    "today+12-m",
				},
			},
			Category: 7, // Programming category
			Property: "",
		}, "de")

	if err != nil {
		log.Fatal(err)
	}

	overTime, err := gogtrends.InterestOverTime(ctx, explore[0], "de")

	if err != nil {
		log.Fatal(err)
	}

	log.Printf("%+v", overTime)

world wide trends and average search count

Hi,

is there a possibility to get a comparrison between items with geo world wide. Also the UI shows me some average search count when comparing keywords, is there any way to get this average value?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.