概述

pytrends 程式庫中的 realtime_trending_searches() 函式可讓您取得 Google 上的即時熱門搜尋。透過分析這些資料,您可以洞察吸引受眾目光的最新趨勢與主題,協助您建立即時、貼切且吸引人的內容。

本教學將涵蓋以下內容:

  1. 匯入所需的程式庫
  2. 設定 pytrends 請求
  3. 取得即時熱門搜尋資料
  4. 分析結果

取得即時熱門搜尋資料

首先,我們需要匯入所需的程式庫並設定 pytrends 請求。

from pytrends.request import TrendReq

# Set up pytrends request
pytrends = TrendReq(hl='en-US', tz=360)

接著,我們將使用 realtime_trending_searches() 函式取得 Google 上目前的即時熱門搜尋。

# Retrieve real-time trending searches data
realtime_trending_searches = pytrends.realtime_trending_searches(pn='US')

這將回傳一個 DataFrame,其中包含美國目前的即時熱門搜尋。

分析結果

現在,我們可以分析即時熱門搜尋資料,以找出吸引受眾目光的最新趨勢與主題。

# Display the top 10 real-time trending searches
print(realtime_trending_searches.head(10))

這段程式碼將顯示前 10 個即時熱門搜尋,為您提供吸引受眾目光的最新趨勢與主題的寶貴洞察。

結論

本文示範了如何使用 pytrends 程式庫中的 realtime_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