# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import requests
from bs4 import BeautifulSoup
import json
import pandas as pd

res = requests.get('https://www.twse.com.tw/zh/page/announcement/punish.html')

res = requests.get('https://www.twse.com.tw/announcement/punish?response=json&startDate=&endDate=&stockNo=&sortKind=&querytype=&selectType=&proceType=&remarkType=&radioType=&_=1628090224776')
# soup = BeautifulSoup(res.text)
# print(soup.get_text())
# print(soup.select('data'))
txt = json.loads(res.text)
# print(txt['creditTitle'])
# print(txt['data'][0])
df = pd.read_json(res.text, orient ='index')
df

lst = txt['data']
df2 = pd.DataFrame(lst, columns =['編號','公布日期','證券代號','證券名稱','累計','處置條件','處置起迄時間','處置措施','處置內容'])
del df2['處置內容']
del df2['編號']
df2.loc[df2['證券代號'].str.len() == 4]
# df2



StarcoderdataJupyterScriptsDedupFiltered