Skip to content

Instantly share code, notes, and snippets.

@Asoul
Created February 27, 2017 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Asoul/541ff860332de92ef586156ac0cb480e to your computer and use it in GitHub Desktop.
Save Asoul/541ff860332de92ef586156ac0cb480e to your computer and use it in GitHub Desktop.
import requests
import time
endpoint = 'http://mis.twse.com.tw/stock/api/getStockInfo.jsp'
targets = ['0050']
timestamp = int(time.time() * 1000 + 1000000)
channels = '|'.join('tse_{}.tw'.format(target) for target in targets)
query_url = '{}?_={}&ex_ch={}'.format(endpoint, timestamp, channels)
req = requests.session()
req.get('http://mis.twse.com.tw/stock/index.jsp')
print(query_url)
response = req.get(query_url)
print(response.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment