我正在使用pytrends在google趋势中搜索一个词,并在数据框中获取索引。 该文档具有pytrends.suggestions()函数和pytrends.related_topics(),但并未明确说明如何使用它来优化搜索?
代码:
from pytrends.request import TrendReq
pytrends = TrendReq(hl='en-US', tz=360)
kw_list = ["jason mraz"]
pytrends.build_payload(kw_list, cat=3, timeframe='today 3-m', geo='US', gprop='')
print pytrends.related_topics()
给出输出:
{u'jason mraz': mid title \
0 /m/0259r0 Jason Mraz
1 /g/1s05vjwr9 I'm Yours
2 /g/1q5j6d270 Lucky
3 /m/05b2qn_ Lucky
4 /m/07xzm Ukulele
5 /m/0bb84c3 I'm yours
6 /m/02bjj5 Red Rocks Amphitheatre
7 /g/1q5j4w2hk 93 Million Miles
8 /m/01h1bf Today
9 /m/06jnhk Ravinia Festival
10 /g/1q5j9_wzt I Won't Give Up
11 /g/1s05rcnf2 A Beautiful Mess
12 /m/096_l SPARC
13 /m/02w4fkq Colbie Caillat
14 /m/0380lh Deer Valley Resort
15 /m/0dmjyx7 Raining Jane
16 /m/02h7gb Jack Johnson
17 /m/09c7v Central Park
18 /g/1q617w8yn Quiet
19 /m/03m8yrc We Sing. We Dance. We Steal Things.
20 /m/02q3w3v OneRepublic
21 /g/1q5jx687v Unlonely
22 /g/1s05p1dp8 More Than Friends
type value
0 American singer-songwriter 100
1 Song by Jason Mraz 9
2 Song by Jason Mraz 5
3 Song by Colbie Caillat, Jason Mraz, and Timoth... 4
4 Guitar 3
5 Song by Jason Mraz 2
6 Amphitheater in Jefferson County, Colorado 1
7 Song by Jason Mraz 1
8 American talk show 1
9 Music Festival 1
10 Song by Jason Mraz 1
11 Song by Jason Mraz 1
12 Computer processor 1
13 American singer-songwriter 1
14 Ski resort in Park City, Utah 0
15 Musical group 0
16 Musician 0
17 Park in New York City, New York 0
18 Song by Jason Mraz 0
19 Studio album by Jason Mraz 0
20 Pop band 0
21 Song by John Prine 0
22 Song by Inna 0 }
以退出代码0结束的过程
现在,如果我只想要类型的结果:“美国歌手兼作词人”该怎么做?请帮忙。
这是github文档的链接: https://github.com/GeneralMills/pytrends/blob/master/README.md