`http://www.pbc.gov.cn/diaochatongjisi/116219/116319/index.html
from selenium import webdriver as wd
import pandas as pd
cps = wd.ChromeOptions()
cps.add_argument('--headless')
bs = wd.Chrome(options=cps)
bs.get('http://www.pbc.gov.cn/diaochatongjisi/resource/cms/2018/04/2018041118065466576.htm')
data=bs.page_source
## bs.find_elements_by_css_selector
table=bs.find_element_by_xpath('//*[@id="社会融资规模增量2016-12_19671"]/table') # ele.send_keys("python"),ele.click() ele.text
pd.set_option('display.width', None)
df = pd.read_html(data)[0] # pd.read_html() 返回为list,list[0]为dataFrame
df.to_csv("file_name",encoding="utf_8_sig")
bs.quit()
效果如下:
企业-业绩-利润表
http://data.eastmoney.com/bbsj/201909/lrb.html