I got this data from Python using tabulate, so please help me.

Asked 2 years ago, Updated 2 years ago, 19 views

import pandas as pd

import requests

from bs4 import BeautifulSoup

from tabulate import tabulate

import time

url = "http://comp.fnguide.com/SVO2/ASP/SVD_Main.asp?
pGB=1&gicode=A005930&cID=&MenuYn=Y&ReportGB=&NewMenuID=101&stkGb=701"


res = requests.get(url)
soup = BeautifulSoup(res.content, "lxml")
table = soup.find_all("table")
df = pd.read_html(str(table))

print(tabulate(df[0], headers="keys", tablefmt="psql"))

In order to obtain the data of the recount, the above code was created.

My next step goal is to get only the 'number of issued shares (common shares/preferred shares)' from the print (not the entire row, just this part).

How do I make a code?

If tabulate is inconvenient, is there any other way?

python

2022-09-20 19:04

1 Answers

print(df[0].iloc[6, 1]) #### 5,969,782,550/ 822,886,700

botong, useon = list(df[0].iloc[6, 1].split('/'))
print(botong, useon) #### 5,969,782,550  822,886,700
botong = int(botong.replace(',', ''))
useon = int(useon.replace(',', ''))
print(botong, useon) #### 5969782550 822886700


2022-09-20 19:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.