-
-
Save shihyu/30fce05f8fee1712cae33aef5b5179c0 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