Created
June 5, 2020 12:46
-
-
Save linzino7/41292cdec681834f025cd2d634a02b13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#引入函式庫 | |
import requests | |
import json | |
# 超連結 | |
url = 'https://www.google.com.tw/maps/preview/review/listentitiesreviews?authuser=0&hl=zh-TW&gl=tw&pb=!1m2!1y3765758546651144975!2y6093113884180453713!2m2!1i0!2i10!3e2!4m5!3b1!4b1!5b1!6b1!7b1!5m2!1sdzvaXrvAMImImAXHsLPICA!7e81' | |
# 發送get請求 | |
text = requests.get(url).text | |
# 取代掉特殊字元,這個字元是為了資訊安全而設定的喔。 | |
pretext = ')]}\'' | |
text = text.replace(pretext,'') | |
# 把字串讀取成json | |
soup = json.loads(text) | |
# 取出包含留言的List 。 | |
conlist = soup[2] | |
# 逐筆抓出 | |
for i in conlist: | |
print("username:"+str(i[0][1])) | |
print("time:"+str(i[1])) | |
print("comment:"+str(i[3])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment