10
LineBot with Google API 對話式經濟?! Ethan.Y

Line bot with google api

  • Upload
    ethan-y

  • View
    671

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Line bot with google api

LineBot with Google API對話式經濟?!

Ethan.Y

Page 2: Line bot with google api

思考流程

● 使用者跟LineBot講話。

● LineBot填寫Google表單。

● LineBot透過Google API抓取

spreadsheet當中的值。

2

Page 3: Line bot with google api

Google表單

● Google有一個(好用)的功能。

● 設計自己記帳時所需的欄位。

● 取得表單的網址。

● 取得表單點選送出後,<form>當中

action的網址。

3

Page 4: Line bot with google api

Google表單 cont.

● 該回傳那些值?

● 利用Burp Suite。● 檢視(稍稍分析)原始碼:為了之後

BeautifulSoup。

4

Page 5: Line bot with google api

抓取Google Sheet Value

● 因為只有抓取值,所以可以直接利

用API Key的方式。

● 如果需要寫入,則需透過OAuth進行驗證。(目前發現是這樣)

5

Page 6: Line bot with google api

抓取Google Sheet Value cont.

● 取得Google API Key。● 進入Google API管理員。

● 需要建立一個專案,並且啟用sheet的API。

● 點選憑證→建立憑證→產生API金鑰。

6

Page 7: Line bot with google api

抓取Google Sheet Value cont.

● 使用Google API。● 取得sheet ID(在網址類的部分,d

之後,edit之前)。● 設定range。● 點選執行→取得API語法。

7

Page 8: Line bot with google api

執行畫面

● 目前版本的程式有兩個功能:

○ 查字典。

○ 記帳。

● 查字典的部分,會將輸入(D之後的

部分)丟到YAHOO字典進行查詢,

並且將結果回傳回來。

● 記帳的部分,則如同前面所說,會

填寫表單並送出,並且在輸入(L/l)的當下,會利用Google API進行記

帳紀錄查詢結果。

8

Page 9: Line bot with google api

Python Package

● 因為這次的實作還是跟爬蟲有點

關係,所以用到的package有點類

似。

● requests● BeautifulSoup4● json● time● ...

9

Page 10: Line bot with google api

End by [email protected]

10