GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.22k stars 813 forks source link

"Rising" related topics instead of "Top" #337

Closed danipolo closed 4 years ago

danipolo commented 4 years ago

Hi,

I found this code and I'm trying to figure out how to get the related topics ordered by "Rising". Right now it looks like it's only available the Top numbers.

{'bitcoin':               mid                     title       type  value
0      /m/05p0rrx                   Bitcoin   Currency    100
1       /m/01d_1l                     Price      Topic     45
2        /m/09nqf      United States Dollar   Currency      4
3       /m/0bhr4z                     Value  Economics      2
4       /m/0cncxk                    Trader    Finance      2
5      /m/0vpj4_b            Cryptocurrency      Topic      2
6       /m/015wzt                     Chart      Topic      2
7       /m/02_vjy                    Wallet      Topic      2
8        /m/0ny80          Confidence trick      Topic      1
9   /g/11f1059m3c     Cryptocurrency wallet      Topic      1
10     /m/0wr3qjq                  Coinbase      Topic      1
11    /m/0138n0j1                Blockchain      Topic      1
12       /m/0242l                      Coin      Topic      1
13    /m/0108bn2x                  Ethereum      Topic      1
14       /m/0cldt  Automated teller machine      Topic      1
15       /m/0dvld              Kate Winslet    Actress      0
16      /m/01qmkt               White paper      Topic      0
17      /m/08x2nq                    Ledger      Topic      0
18       /m/06lpz                  Roulette       Game      0
19       /m/034dj                  Gambling      Topic      0
20      /m/0c131z                     Libra  Astrology      0
21      /m/02mxjp      Exchange-traded fund      Topic      0
22     /m/046632s   Biophysical environment      Topic      0
23       /m/0sxyn                     Short      Topic      0

And here's my code:

from pytrends.request import TrendReq

# Login to Google. Only need to run this once, the rest of requests will use the same session.
pytrend = TrendReq()

# Create payload and capture API tokens. Only needed for interest_over_time(), interest_by_region() & related_queries()
pytrend.build_payload(kw_list=['bitcoin'], timeframe='now 4-H', geo='GB', gprop='')

related_topics_dict = pytrend.related_topics()
print(related_topics_dict)

How can I see the rising only?

Thanks

TickTack-z commented 4 years ago

I think it will print a dictionary with both rising terms and top terms. This is my output using your code: {'bitcoin': {'rising': ...... , 'top': ......}

My version is pytrends 4.7.1