从巨潮网络下载财报数据,觉得手动比较麻烦,就做了一个简单的python脚本。具体主要代码如下:
driver = webdriver.PhantomJS(executable_path='浏览器引擎/自己使用phantomjs')
if int(stockNumber) >= 600000:
dst_url = 'http://www.cninfo.com.cn/cninfo-new/disclosure/sse'
else:
dst_url = 'http://www.cninfo.com.cn/cninfo-new/disclosure/szse'
driver.get(dst_url)
prefixpath = "文件夹路径"
driver.find_element_by_class_name("input-stock").send_keys(stockNumber)
driver.find_element_by_xpath("//ul[@id='stock_list']/li[1]/a").click()
prefixpathname = prefixpath+stockNumber+"/"
if os.path.exists(prefixpathname):
pass
else:
os.mkdir(prefixpathname)
#driver.find_element_by_xpath("//ul[@id='stock_list']/li[1]").send_keys(Keys.ENTER)
#切换网页,以