概述
pytrends 程式庫中的 trending_searches() 函式可讓您取得 Google 上目前的熱門搜尋。透過分析這些資料,您可以洞察吸引受眾目光的最新趨勢與主題,協助您建立即時且貼切的內容。
本教學將涵蓋以下內容:
- 匯入所需的程式庫
- 設定
pytrends請求 - 取得熱門搜尋資料
- 分析結果
取得熱門搜尋資料
首先,我們需要匯入所需的程式庫並設定 pytrends 請求。
from pytrends.request import TrendReq
# Set up pytrends request
pytrends = TrendReq(hl='en-US', tz=360)
接著,我們將使用 trending_searches() 函式取得 Google 上目前的熱門搜尋。
# Retrieve trending searches data
trending_searches = pytrends.trending_searches(pn='united_states')
這將回傳一個 DataFrame,其中包含美國目前的熱門搜尋。
分析結果
現在,我們可以分析熱門搜尋資料,以找出內容創作與最佳化的新機會。
# Display the top 10 trending searches
print(trending_searches.head(10))
這段程式碼將顯示前 10 個熱門搜尋,為您提供吸引受眾目光的最新趨勢與主題的寶貴洞察。
結論
本文示範了如何使用 pytrends 程式庫中的 trending_searches() 函式追蹤 Google 上的熱門搜尋。透過分析這些資料,您可以保持領先,並發現內容創作與最佳化的新機會。本教學涵蓋了從設定 pytrends 請求到分析結果的完整流程,包括收集與分析熱門搜尋資料的各個步驟。善用這些洞察,您可以為受眾建立即時且貼切的內容。
NOTE : pytrends uses an unofficial API. Please use here for issues.
SAMPLE CODE : https://github.com/hobbyworker/google-trend-for-python