Skip to content

Instantly share code, notes, and snippets.

@ctosib
ctosib / grapimage.py
Created January 4, 2017 08:37
利用tkinter顯示網路上的圖片
import requests
import Tkinter as tk
import io
from PIL import Image,ImageTk
class Mainapplication(tk.Frame):
def __init__(self,master=None):
tk.Frame.__init__(self,master)
self.pack()
self.createwidget()
@ctosib
ctosib / ReadLocalFile.html
Created January 3, 2017 09:38
如何利用javascript ReadFile API去讀取local的File
<html>
<head>
</head>
<body>
<input type="file" id="files" name="files" multiple />
<div id="output">
</div>
<script>
function openFile(event){
@ctosib
ctosib / readTextFile.html
Created December 31, 2016 05:55
Use Javascript to read a text file
<html>
<head>
</head>
<body >
<input type='file' onchange='openFile(event)'><br>
<div id='output'>
</div>
<script>
@ctosib
ctosib / LinebotWithGoogle.py
Last active March 28, 2024 03:48
將Linebot與Google sheet API做結合,製作記帳機器人
#encoding=UTF-8
"""
Author:Ethan Yang
Datetime:2016/12/29
Purpose:
1.對話是經濟?!
2.利用Line當作輸入指令的窗口。
3.記帳。
4.查詢單字
"""
@ctosib
ctosib / googleform.py
Created December 27, 2016 16:43
利用requests和beautifulsoup成功填寫google表單
import requests
from bs4 import BeautifulSoup as bs
#form的action網址
url = 'https://docs.google.com/forms/d/e/1FAIpQLSfG0Jrb1XB0_6bnStQqI3LTh1vJxzNf92X38O9n9gINR3pERQ/formResponse'
r = requests.Session()
res = r.get('https://docs.google.com/forms/d/e/1FAIpQLSfG0Jrb1XB0_6bnStQqI3LTh1vJxzNf92X38O9n9gINR3pERQ/viewform')
soup = bs(res.content,'html.parser')
inputlist = soup.find_all('input')
@ctosib
ctosib / ServiceAccount.py
Created December 20, 2016 09:27
讀取Google Sheet via google API
from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http
from apiclient.discovery import build
"""
Reference:
1.Google OAuth 2.0 for Service Account
2..OAuth 2.0 API scope:https://developers.google.com/identity/protocols/googlescopes#sheetsv4
3..Install python api library:https://developers.google.com/api-client-library/python/start/installation
4..Google Sheet api:https://developers.google.com/resources/api-libraries/documentation/sheets/v4/python/latest/index.html
@ctosib
ctosib / FirstLineBot.py
Last active February 10, 2017 02:20
Purpose:For Practice
#encoding=UTF-8
"""
Datetime:2016/12/17
Author:Ethan.Y
Purpose:
1.練習使用Line Messaging API
2.練習閱讀官方的Document
Functions:
1.收到訊息之後回復
2.若收到的訊息當中還有(掰掰)字串,則回應特定內容
@ctosib
ctosib / Facebook message bot(in python)
Created December 15, 2016 02:46
第一隻練習的facebook bot機器人,使用者說什麼,機器人就說什麼
#必須要import request,才可以在下面的程式碼當中抓到get or post的參數
from flask import Flask,request
import json
import requests
app = Flask(__name__)
@app.route("/" ,methods=['GET'])
def hello():
if request.args.get('hub.mode')=='subscribe' and request.args.get('hub.challenge'):
@ctosib
ctosib / gist:8f35670a137d7ce51d418db6005feeac
Last active December 14, 2016 06:36
Flask的第一個程式
from flask import Flask
app = Flask(__name__)
@app.route("/" , methods=['GET'])
def index():
return "hello world", 200
if __name__=='__main__':
app.run()