Closed brentbiglin closed 7 years ago
Hi @brentbiglin. Did you try to use the hl
parameter (preferred language) in the optionsObject
? Set hl='ar' for Arabic. I actually haven't tried this at all so I'm not sure how it will affect the results if at all...
Hey, Patrick. I appreciate you taking a look. I had the language set to Arabic, but it was coming out encoded. This was my solution:
console.log(JSON.stringify(JSON.parse(res)));
It worked like a charm!
I can set up a pull request if you want to take a look and maybe merge it.
Brent
On Aug 8, 2017 21:59, "Patrick Trasborg" notifications@github.com wrote:
Hi @brentbiglin https://github.com/brentbiglin. Did you try to use the hl parameter (preferred language) in the optionsObject? Set hl='ar' for Arabic https://sites.google.com/site/tomihasa/google-language-codes. I actually haven't tried this at all so I'm not sure how it will affect the results if at all...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat310/google-trends-api/issues/68#issuecomment-321138953, or mute the thread https://github.com/notifications/unsubscribe-auth/AVIs3dLOn5jQO1y-XTd9rim8nQXowIYcks5sWSCXgaJpZM4Ou1D8 .
@brentbiglin Hmm, do you mean it was coming out as nested [object]? I'm not sure how JSON.stringify(JSON.parse(res))
would have solved a decoding problem
@brentbiglin if you could post an example of the encoded results that would be great!
Sorry, Patrick! Got caught up with work. With the JSON.stringify(JSON.parse(res)), I get the following output:
~/node/node_modules/google-trends-api $ node relatedQueries.js سلام
{"default":{"rankedList":[{"rankedKeyword":[{"query":"يا
سلام","value":100,"formattedValue":"100","link":"/"},{"query":"سلام
عليك","value":55,"formattedValue":"55","link":"/"},{"query":"سلام
للنونو","value":35,"formattedValue":"35","link":"/"},{"query":"يا نبي سلام
عليك","value":20,"formattedValue":"20","link":"/"},{"query":"ماهر
زين","value":20,"formattedValue":"20","link":"/"},{"query":"ماهر زين سلام
عليك","value":20,"formattedValue":"20","link":"/"},{"query":"محمد
سلام","value":15,"formattedValue":"15","link":"/"},{"query":"سلام يا
صاحبى","value":15,"formattedValue":"15","link":"/"},{"query":"سلام يا
صاحبي","value":15,"formattedValue":"15","link":"/"},{"query":"احمد
سلام","value":15,"formattedValue":"15","link":"/"},{"query":"تعظيم
سلام","value":15,"formattedValue":"15","link":"/"},{"query":"صور
سلام","value":10,"formattedValue":"10","link":"/"},{"query":"سلام
دانك","value":10,"formattedValue":"10","link":"/"},{"query":"عبد
سلام","value":10,"formattedValue":"10","link":"/"},{"query":"سمر
سلام","value":10,"formattedValue":"10","link":"/"},{"query":"اغنية يا نبي
سلام عليك","value":10,"formattedValue":"10","link":"/"},{"query":"اغنية
سلام للنونو","value":10,"formattedValue":"10","link":"/"},{"query":"يا نبي
سلام عليك ماهر
زين","value":10,"formattedValue":"10","link":"/"},{"query":"مهرجان
سلام","value":10,"formattedValue":"10","link":"/"},{"query":"فيلم سلام يا
صاحبى","value":5,"formattedValue":"5","link":"/"},{"query":"يا نبي سلام
عليك mp3","value":5,"formattedValue":"5","link":"/"},{"query":"يا نبى سلام
عليك","value":5,"formattedValue":"5","link":"/"},{"query":"ماهر زين
mp3","value":5,"formattedValue":"5","link":"/"},{"query":"سلام يا اغلى
حبيب","value":5,"formattedValue":"5","link":"/"},{"query":"اغنية تعظيم
سلام","value":5,"formattedValue":"5","link":"/"}]},{"rankedKeyword":[{"query":"سلام
عليك","value":1701100,"formattedValue":"الطفرة","link":"/"},{"query":"يا
نبي سلام
عليك","value":699500,"formattedValue":"الطفرة","link":"/"},{"query":"ماهر
زين","value":554500,"formattedValue":"الطفرة","link":"/"},{"query":"ماهر
زين سلام
عليك","value":551450,"formattedValue":"الطفرة","link":"/"},{"query":"محمد
سلام","value":545250,"formattedValue":"الطفرة","link":"/"},{"query":"سلام
يا
صاحبي","value":448450,"formattedValue":"الطفرة","link":"/"},{"query":"احمد
سلام","value":426150,"formattedValue":"الطفرة","link":"/"},{"query":"تعظيم
سلام","value":406800,"formattedValue":"الطفرة","link":"/"},{"query":"صور
سلام","value":387350,"formattedValue":"الطفرة","link":"/"},{"query":"سلام
دانك","value":369850,"formattedValue":"الطفرة","link":"/"},{"query":"اغنية
يا نبي سلام
عليك","value":339550,"formattedValue":"الطفرة","link":"/"},{"query":"اغنية
سلام
للنونو","value":326550,"formattedValue":"الطفرة","link":"/"},{"query":"يا
نبي سلام عليك ماهر
زين","value":277100,"formattedValue":"الطفرة","link":"/"},{"query":"مهرجان
سلام","value":252950,"formattedValue":"الطفرة","link":"/"},{"query":"فيلم
سلام يا
صاحبى","value":232050,"formattedValue":"الطفرة","link":"/"},{"query":"يا
نبي سلام عليك
mp3","value":230300,"formattedValue":"الطفرة","link":"/"},{"query":"يا نبى
سلام
عليك","value":225750,"formattedValue":"الطفرة","link":"/"},{"query":"ماهر
زين
mp3","value":222700,"formattedValue":"الطفرة","link":"/"},{"query":"سلام يا
اغلى
حبيب","value":212400,"formattedValue":"الطفرة","link":"/"},{"query":"اغنية
تعظيم
سلام","value":211500,"formattedValue":"الطفرة","link":"/"},{"query":"نجاح
سلام","value":201750,"formattedValue":"الطفرة","link":"/"},{"query":"عليك
سلام
الله","value":176100,"formattedValue":"الطفرة","link":"/"},{"query":"يانبى
سلام
عليك","value":170800,"formattedValue":"الطفرة","link":"/"},{"query":"يانبي
سلام
عليك","value":169450,"formattedValue":"الطفرة","link":"/"},{"query":"يا
سلام","value":600,"formattedValue":"+600%","link":"/"}]}]}}
Without it, I would get this:
~/node/node_modules/google-trends-api $ node examples.js
{"default":{"rankedList":[{"rankedKeyword":[{"query":"\u0648\u0638\u0627\u0626\u0641
\u0642\u0637\u0631","value":100,"formattedValue":"100","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":100,"formattedValue":"100","link":"/"},{"query":"\u0648\u0638\u0627\u0626\u0641","value":100,"formattedValue":"100","link":"/"},{"query":"\u0627\u063a\u0646\u064a\u0629
\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":50,"formattedValue":"50","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u064a\u0648\u0645","value":50,"formattedValue":"50","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u0649","value":50,"formattedValue":"50","link":"/"},{"query":"\u0645\u0643\u0649
\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":45,"formattedValue":"45","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u0649 \u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":40,"formattedValue":"40","link":"/"},{"query":"\u0648\u0638\u0627\u0626\u0641
\u0641\u064a
\u0642\u0637\u0631","value":40,"formattedValue":"40","link":"/"},{"query":"\u0628\u0646\u0643
\u0642\u0637\u0631","value":40,"formattedValue":"40","link":"/"},{"query":"\u0635\u0648\u0631
\u0642\u0637\u0631","value":35,"formattedValue":"35","link":"/"},{"query":"\u0648\u0638\u0627\u0626\u0641
\u0641\u0649
\u0642\u0637\u0631","value":30,"formattedValue":"30","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u0646\u062f\u0649","value":30,"formattedValue":"30","link":"/"},{"query":"\u0627\u0644\u0627\u0645\u0627\u0631\u0627\u062a","value":30,"formattedValue":"30","link":"/"},{"query":"\u0627\u062e\u0628\u0627\u0631
\u0642\u0637\u0631","value":30,"formattedValue":"30","link":"/"},{"query":"\u062f\u0648\u0644\u0629
\u0642\u0637\u0631","value":25,"formattedValue":"25","link":"/"},{"query":"\u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629","value":25,"formattedValue":"25","link":"/"},{"query":"\u0637\u0631\u0628
\u0642\u0637\u0631","value":25,"formattedValue":"25","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0647","value":25,"formattedValue":"25","link":"/"},{"query":"\u0627\u063a\u0646\u064a\u0629
\u0627\u062d\u0645\u062f \u0645\u0643\u0649 \u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":25,"formattedValue":"25","link":"/"},{"query":"\u0627\u0645\u064a\u0631
\u0642\u0637\u0631","value":20,"formattedValue":"20","link":"/"},{"query":"\u0628\u0646\u0643
\u0642\u0637\u0631
\u0627\u0644\u0648\u0637\u0646\u064a","value":20,"formattedValue":"20","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u064a","value":20,"formattedValue":"20","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629
mp3","value":15,"formattedValue":"15","link":"/"},{"query":"\u0634\u0627\u062a
\u0642\u0637\u0631","value":15,"formattedValue":"15","link":"/"}]},{"rankedKeyword":[{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":823650,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u063a\u0646\u064a\u0629
\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":410000,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u064a\u0648\u0645","value":407700,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u0649","value":400750,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0645\u0643\u0649
\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":366850,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u0649 \u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":351400,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u0646\u062f\u0649","value":238350,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0637\u0631\u0628
\u0642\u0637\u0631","value":215750,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0647","value":213000,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u063a\u0646\u064a\u0629
\u0627\u062d\u0645\u062f \u0645\u0643\u0649 \u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":205950,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u0645\u064a\u0631
\u0642\u0637\u0631","value":175350,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u064a","value":147500,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629
mp3","value":121750,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u0644\u0639\u0627\u0628
\u0642\u0637\u0631","value":120850,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u062d\u0645\u062f
\u0645\u0643\u064a \u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":111950,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0644\u0644\u0645\u0627\u0644
\u0648\u0627\u0644\u0627\u0639\u0645\u0627\u0644","value":104300,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629
\u0643\u0644\u0645\u0627\u062a","value":94200,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u0644\u0645\u062c\u0644\u0633
\u0627\u0644\u0627\u0639\u0644\u0649
\u0644\u0644\u062a\u0639\u0644\u064a\u0645
\u0642\u0637\u0631","value":93750,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u062a\u062d\u0645\u064a\u0644
\u0627\u063a\u0646\u064a\u0629 \u0642\u0637\u0631
\u0627\u0644\u062d\u064a\u0627\u0629","value":86250,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0627\u0644\u0628\u0648\u0645
\u0642\u0637\u0631","value":84000,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0648\u0638\u0627\u0626\u0641
\u0627\u0644\u0643\u0648\u064a\u062a","value":81550,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0648\u0638\u0627\u0626\u0641
\u062e\u0627\u0644\u064a\u0629 \u0641\u0649
\u0642\u0637\u0631","value":80200,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0642\u0637\u0631
\u0627\u0644\u0627\u062d\u0644\u0627\u0645","value":79050,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0628\u0646\u0643
\u0642\u0637\u0631
\u0627\u0644\u0648\u0637\u0646\u0649","value":77300,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"},{"query":"\u0643\u062a\u0627\u0628
\u0642\u0637\u0631
\u0627\u0644\u0646\u062f\u0649","value":77150,"formattedValue":"\u0627\u0644\u0637\u0641\u0631\u0629","link":"/"}]}]}}
On Fri, Aug 18, 2017 at 9:52 AM, Patrick Trasborg notifications@github.com wrote:
@brentbiglin https://github.com/brentbiglin if you could post an example of the encoded results that would be great!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat310/google-trends-api/issues/68#issuecomment-323375235, or mute the thread https://github.com/notifications/unsubscribe-auth/AVIs3RaGndJtimQbJsJp6jM09vp5No-gks5sZaUpgaJpZM4Ou1D8 .
@brentbiglin no worries. Thanks for posting the example. That's cool that JSON.parse
decodes unicode. My only worry is if the result is not valid JSON
then an error will be thrown... This is similar to #63. Maybe I will JSON.parse
. If there is an error just catch it and return what the original string was without JSON.parse
... The other option is to decodeURIComponent
, but that also throws an error if used incorrectly.
@brentbiglin Made a PR for this #74, thanks!
Arabic really complicates things digitally! Glad to be of help.
On Aug 25, 2017 21:07, "Patrick Trasborg" notifications@github.com wrote:
@brentbiglin https://github.com/brentbiglin Made a PR for this #74 https://github.com/pat310/google-trends-api/pull/74, thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat310/google-trends-api/issues/68#issuecomment-325073539, or mute the thread https://github.com/notifications/unsubscribe-auth/AVIs3cJBmCOplF04_0tD-Jc0ceaq5xHDks5sb33igaJpZM4Ou1D8 .
Hello! I'm wondering if it would be possible for the output to be decoded. I'm using this for a project in the Arabic language and the output is encoded unicode text.