Analytic SEO with Python
1. Pytrend
Install Pytrends
! pip install pytrends
Query by PyTrends
from pytrends.request import TrendReq
pytrend = TrendReq(hl = 'vi-VN', tz = 360)
pytrend.build_payload(kw_list = ['lập trình python'])
related = pytrend.related_queries()
print(related['lập trình python']['top'])
WordCloud
Install
! pip install underthesea
! pip install wordcloud
Pre Processing
words = word_tokenize(body)
words= [word.lower() for word in words if word.lower() not in [',', 'và', 'với', '.', 'là', ':', ')', '(']]
frequencies = Counter(words)
WordCloud
plt.rcParams['figure.figsize'] = (20, 10)
wordCloud = WordCloud(width=1000, height=800, background_color='white')
wc = wordCloud.fit_words(frequencies= frequencies)
plt.imshow(wc)
plt.show()
Page Rank
from networkx import pagerank, DiGraph, draw
dg = DiGraph()
dg.add_edge(1, 2)
dg.add_edge(2, 3)
dg.add_edge(2, 5)
dg.add_edge(3, 1)
dg.add_edge(4, 2)
dg.add_edge(5, 3)
dg.add_edge(5, 4)
draw(dg, with_labels=[1, 2, 3, 4, 5])