Created
February 16, 2016 15:31
-
-
Save flyakite/0bfc413120795a71e646 to your computer and use it in GitHub Desktop.
This file contains 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 BeautifulSoup, requests | |
r=requests.post('http://www.twse.com.tw/ch/trading/exchange/BWIBBU/BWIBBU.php', {'STK_NO':2330, 'myear': 2016, 'mmon':2}) | |
soup = BeautifulSoup.BeautifulSoup(r.content) | |
table = soup.find('table', {'class':'board_trad'}) | |
with open('out2.csv', 'w') as f: | |
trs = table.findAll('tr') | |
for tr in trs: | |
tds = tr.findAll('td') | |
f.write(', '.join([td.text.encode('utf-8') for td in tds]) + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment