這個程式能根據 goolge map 中的 place_id 爬取指定店家的評論,包含評論者的名稱、評論者個人頁面的 url 等資訊,並以 csv 的形式儲存。
Selenium: https://pypi.org/project/selenium/
Beautiful Soup: https://www.crummy.com/software/BeautifulSoup/bs4/doc/
Pandas: https://pandas.pydata.org/docs/getting_started/install.html
tqdm: https://github.com/tqdm/tqdm
可透過以下指令取得:
pip install -r requirements.txt
將餐廳清單傳入 get_all_restaurant_comment() 即可。舉例來說,如果要爬取 restaurant_list1 中所有餐廳的評論,呼叫的方式如下:
get_all_restaurant_comment('restaurant_list1')
餐廳清單皆存在這個路徑下:
Google-map-review-crawler/restaurant_spilt_list/
get_all_restaurant_comment() 會從這個資料夾讀取餐廳清單。
所有餐廳的評論都會存入 /result 資料夾中,不同清單的餐廳則會存在以餐廳清單名稱命名的資料夾底下,如 restaurant_list1 中所有餐廳的評論的儲存路徑會是:
Google-map-review-crawler/result/restaurant_list1/
options.add_argument('--headless')