-
-
Save toomore/563936 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# 抓取最近上市或是上櫃公司資料 | |
# By Toomore | |
class iiqy(object): | |
def __init__(self, t, page): | |
''' | |
t: | |
tse 上市 | |
otc 上櫃 | |
page:網頁上的總頁數 | |
最後輸出成 *.iqy 檔,帶入 Excel 匯入外部資料使用 | |
''' | |
iqy = {} | |
iqy['tse'] = '''WEB | |
1 | |
http://www.twse.com.tw/ch/listed/listed_company/new_listing.php?page=%s | |
Selection=7 | |
Formatting=None | |
PreFormattedTextToColumns=True | |
ConsecutiveDelimitersAsOne=True | |
SingleBlockTextImport=False | |
DisableDateRecognition=False | |
DisableRedirections=False''' | |
iqy['otc'] = '''WEB | |
1 | |
http://www.otc.org.tw/ch/regular_emerging/apply_schedule/latest/latest_listed_companies.php?stk_code=&select_year=ALL&topage=%s | |
Selection=93 | |
Formatting=None | |
PreFormattedTextToColumns=True | |
ConsecutiveDelimitersAsOne=True | |
SingleBlockTextImport=False | |
DisableDateRecognition=False | |
DisableRedirections=False''' | |
for i in range(page): | |
iqy_op = iqy[t] % i | |
f = open('%s_%s.iqy' % (t,i), 'wt') | |
f.write(iqy_op) | |
f.close | |
print '%s %s' % (t, page) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment