TheNetsky / Microsoft-Rewards-Script

Automated Microsoft Rewards script, using TypeScript, Cheerio and Playwright.
189 stars 44 forks source link

can't search , because getGoogleTrends() return 404 #136

Closed While-Shark closed 1 month ago

While-Shark commented 1 month ago

https://trends.google.com/trends/api/dailytrends?geo=${geoLocale}&hl=en&ed=${formattedDate}&ns=15

can't search , because getGoogleTrends() return 404

TheNetsky commented 1 month ago

Works fine for me.

What happens when you visit https://trends.google.com/trends/api/dailytrends?geo=US&hl=en&ed=20240823&ns=15

While-Shark commented 1 month ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

TheNetsky commented 1 month ago

lol

While-Shark commented 1 month ago

https://trends.google.com/trends/api/dailytrends?geo=US&hl=en&ed=20240823&ns=15 download json.txt on my desktop. like this.. image

it show time out... image

TheNetsky commented 1 month ago

Are you using a proxy by chance?

While-Shark commented 1 month ago

Are you using a proxy by chance?

i always use proxy by V2R**Y

TheNetsky commented 1 month ago

Likely because of your location, iirc the request to Google aren't using the proxy, so it's likely unavailable in your region

While-Shark commented 1 month ago

Likely because of your location, iirc the request to Google aren't using the proxy, so it's likely unavailable in your region

thanks your reply .

i changed getGoogleTrends() code like this.

private async getGoogleTrends(geoLocale: string, queryCount: number): Promise<GoogleSearch[]> {
        const queryTerms: GoogleSearch[] = []
        let i = 0

        geoLocale = (this.bot.config.searchSettings.useGeoLocaleQueries && geoLocale.length === 2) ? geoLocale.toUpperCase() : 'US'

        this.bot.log('SEARCH-GOOGLE-TRENDS', `Generating search queries, can take a while! | GeoLocale: ${geoLocale}`)

        while (queryCount > queryTerms.length) {
            i += 1
            const date = new Date()
            date.setDate(date.getDate() - i)
            // const formattedDate = this.formatDate(date)

            try {
                const request = {
                    url: 'https://api.oioweb.cn/api/common/yiyan',
                    method: 'GET'
                }

                const response = await axios(request)

                const {content,date} = await response.data.result

                if(content){
                    queryTerms.push({
                        topic: content,
                        related: content
                    })
                }

                /*for (const topic of data.default.trendingSearchesDays[0]?.trendingSearches ?? []) {
                    queryTerms.push({
                        topic: topic.title.query.toLowerCase(),
                        related: topic.relatedQueries.map(x => x.query.toLowerCase())
                    })
                }*/

            } catch (error) {
                this.bot.log('SEARCH-GOOGLE-TRENDS', 'An error occurred:' + error, 'error')
            }
        }

        return queryTerms
    }

now it can work better in my region