3 步驟獲取Google Play 中APP數據 - Python 爬蟲

Alan Syue
3 min readFeb 7, 2019

圖片來源: Wikimedia Commons

本文重點結論:

1. 利用 Python、Selenium 獲取 Google play store 上 APP 資訊

2. 可針對 APP 做用戶反饋調查 ( 目前想到的 )

3. 附上程式碼:https://github.com/AlanSyue/google-play-crawler

※ 專案 forked from ranjeet867/google-play-crawler

專案緣起

前些日子在瀏覽 Google play store 上用戶的評論及回饋,有些功能建議或 UI / UX 反饋,都覺得還不錯 ( 雖然沒有到太多 )。

如果是自己 APP 的評論,Google Console 裡面也有提供不錯的評論通知,但如果是想研究其他相似的 APP 呢?

於是我 Google 了一下,想說是不是有套件或是第三方工具使用,但老實說,沒有找到太多的資訊 ( 其實我也還沒想到這些資料可以做什麼厲害的分析 ,目前想到就像上述了解用戶反饋)。

不過偶然間在 GitHub 發現 ranjeet867 大大用 Python 做了一個 Google play store 的 crawler。

仔細去看了一下 data example,剛好有我需要的評論內容,不過剛好發現以下 3 點,所以就 fork 回來調整一下:

  1. 撈取內容的 class name 並非當前名稱,是以示意名稱做標示,有鑑於會需要實際去確認並修改,乾脆就一起更新,如:

原:expatistan_table = soup_expatistan.find(“div”, class_=”id-app-title”)

後:expatistan_table = soup_expatistan.find(“h1”, class_=”AHFaub”)

2. 部分內容經實際觀察,查無此項目數據,故先拿掉,如:評論標題

3. 因為讀取所有評論的頁面為瀑布式,不太確定對方處理方式,故調整為使用 Selenium 的 window.scrollTo 獲取更多評論

使用方式

  1. 安裝下列套件:BeautifulSoup、Selenium
  2. 在 urls 的 list 填入想爬取的 APP Google play store 網址
  3. 開始執行
( 成功執行畫面示意圖 )

以上為此專案使用說明,若有任何問題或錯誤,歡迎指教及建議,謝謝!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Alan Syue
Alan Syue

Written by Alan Syue

Backend Engineer at UPN | Love to share everything

Responses (1)

Write a response

可以試試看用元件的相對位置來抓資料,可以先抓「使用者評論」這個 h3 位置,然後找到它後續的評論列表,列表內的評論排版格式是一樣的,應該就可以抓到所有你要的資料,這個方法也會因網頁改版而無法使用,但可能比較「通用」不同APP的使用者,因為沒辦法確定不同使用者的 class name 是一樣的,但我覺得元件位置應該是一樣的。
另外我覺得這個直接針對 API 爬,畢竟是瀑布式的網頁,一定是 call API,找到對應的 API 會加速你爬資料速度

--