How to read all tables with read_html

Question:

I’m trying to extract a table from link but I can not do it. This is how table show on web:

enter image description here

I used below code to read html:

import requests
import pandas as pd

url = 'https://spib.wooribank.com/pib/Dream?withyou=ENENG0358'
df = pd.read_html(url)[1:4]

df

And here is the Output:

[  Currency      Buy     Sell
 0      USD  1283.06  1238.94
 1      JPY   973.64   940.16
 2      EUR  1379.70  1326.40,
   Currency     Send  Receive
 0      USD  1273.20  1248.80
 1      JPY   966.18   947.62
 2      EUR  1366.58  1339.52,
   Currency      Buy     Sell
 0      USD  1276.13  1248.80
 1      JPY   968.38   947.62
 2      EUR  1373.34  1339.52]

I tried to using f12 to find table class and use attrs to extract bu it raised error that No tables found.

url = 'https://spib.wooribank.com/pib/Dream?withyou=ENENG0358'
df = pd.read_html(url,attrs={"class":"tbl-type-1 txt-c mb20 ui-set-tbl-type"})

So please help me to find the way to extract the data. Another question that is there anyway to extract data after filtering (Reported date).

Thank you.

Asked By: hoa tran

||

Answers:

Use another url to get the data:

df = pd.read_html('https://spib.wooribank.com/pib/jcc?withyou=ENENG0358&__ID=c008822')[0]

Output:

>>> df
   Currency                     Foreign Currency Remittance               Cash          Transaction Standard Rate BOK Standard Rate USA Calculation Rate
   Currency          Currency.1                     Sending Receiving   Buying  Selling Transaction Standard Rate BOK Standard Rate USA Calculation Rate
0       USD                 USA                     1273.20   1248.80  1283.06  1238.94                   1261.00           1247.50               1.0000
1       JPY               Japan                      966.18    947.62   973.64   940.16                    956.90            940.34               0.7588
2       EUR                  EU                     1364.67   1337.65  1377.77  1324.55                   1351.16           1338.01               1.0715
3       GBP                  UK                     1532.79   1502.45  1547.51  1487.73                   1517.62           1499.56               1.2035
4       CAD              Canada                      948.83    930.05   957.94   920.94                    939.44            927.72               0.7450
5       CHF               Swiss                     1377.17   1349.91  1390.40  1336.68                   1363.54           1344.29               1.0813
6       HKD            Hongkong                      162.27    159.07   163.83   157.51                    160.67            158.99               0.1274
7       CNY               China                      187.45    183.75   194.88   176.32                    185.60            183.46               0.1472
8       THB            Thailand                       37.86     37.12    38.23    36.75                     37.49             37.01               0.0297
9       IDR           Indonesia                        8.46      8.30     8.88     7.80                      8.38              8.29               0.0066
10      SEK              Sweden                      119.84    117.48   121.03   116.29                    118.66            117.48               0.0941
11      AUD           Austraila                      882.60    865.14   891.08   856.66                    873.87            858.90               0.6930
12      DKK             Denmark                      183.37    179.75   185.19   177.93                    181.56            179.76               0.1440
13      NOK              Norway                      123.32    120.88   124.54   119.66                    122.10            120.65               0.0968
14      SAR               Saudi                      339.52    332.80   352.96   314.31                    336.16            332.50               0.2666
15      KWD              Kuwait                     4165.59   4083.11  4413.05  3835.65                   4124.35           4080.13               3.2707
16      BHD             Bahrain                     3378.12   3311.24  3545.36  3077.11                   3344.68           3308.76               2.6524
17      AED               U.A.E                      346.80    339.94   360.53   321.06                    343.37            339.63               0.2723
18      SGD           Singapore                      959.90    940.90   969.40   931.40                    950.40            939.24               0.7537
19      MYR            Malaysia                           -         -   307.93   281.29                    296.09            292.98               0.2348
20      NZD          NewZealand                      804.41    788.49   812.14   780.76                    796.45            786.67               0.6316
21      TWD              Taiwan                           -         -    44.40    39.38                     41.89             41.50               0.0332
22      PHP         Philippines                       23.08     22.64    24.91    21.49                     22.86             22.91               0.0181
23      VND             Vietnam                        5.42      5.32     6.00     4.74                      5.37              5.31               0.0043
24      PLN              Poland                      287.98    282.28   307.94   262.32                    285.13            282.14               0.2261
25      RUB              Russia                       17.76     17.42    18.82    15.49                     17.59             17.45               0.0139
26      ZAR        South Africa                       72.22     70.80    77.23    65.79                     71.51             70.62               0.0567
27      INR               India                       15.37     15.07    16.43    14.31                     15.22             15.07               0.0121
28      PKR            Pakistan                           -         -        -        -                      4.58              4.53               0.0036
29      BDT          Bangladesh                           -         -        -        -                     11.78             11.69               0.0093
30      EGP               Egypt                           -         -        -        -                     41.69             41.31               0.0331
31      MXN              Mexico                       66.55     65.25    73.14    58.00                     65.90             65.08               0.0523
32      BRL              Brazil                           -         -   271.92   215.59                    244.98            242.38               0.1943
33      BND              Brunei                           -         -   987.50   892.55                    949.52            939.24               0.7530
34      ILS              Israel                           -         -   391.96   333.90                    362.93            359.03               0.2878
35      JOD              Jordan                           -         -  1848.75  1635.44                   1777.65           1758.65               1.4097
36      CZK  the Czech Republic                           -         -    61.05    52.01                     56.53             56.06               0.0448
37      MNT            Mongolia                           -         -        -        -                      0.36              0.36               0.0003
38      FJD                Fiji                           -         -   611.36   520.80                    566.08            560.13               0.4489
39      KHR            Cambodia                           -         -    33.32    28.40                     30.86             30.50               0.0245
40      TRY             Turkiye                       67.73     66.39    72.42    61.70                     67.06             66.23               0.0532
41      HUF             Hungary                        3.46      3.40     3.70     3.16                      3.43              3.39               0.0027
42      QAR               Qatar                           -         -        -        -                    346.05            342.28               0.2744
43      KZT     ì¹´ì¤í
                                                 -         -        -        -                      2.76              2.73               0.0022
44      NPR              ë
                          ¤í                           -         -        -        -                      9.55              9.43               0.0076
45      XAU             GOLD 1g                    76664.94  75146.84        -        -                  75905.89          75132.42              60.1950
46      XAG           SILVER 1g                           -         -        -        -                    905.87            897.62               0.7184

Update

You can filter data like:

import requests

url = 'https://spib.wooribank.com/pib/jcc'
payload = {
    'withyou': 'ENENG0358',
    '__ID': 'c008822'
}
data = {
    'BAS_DT': '20230207',
    'NTC_DIS': 'B',
}
r = requests.post(url, params=payload, data=data)
df = pd.read_html(r.text)[0]
print(df)

# Output
   Currency                     Foreign Currency Remittance               Cash          Transaction Standard Rate BOK Standard Rate USA Calculation Rate
   Currency          Currency.1                     Sending Receiving   Buying  Selling Transaction Standard Rate BOK Standard Rate USA Calculation Rate
0       USD                 USA                     1273.70   1249.30  1283.57  1239.43                   1261.50           1247.50               1.0000
1       JPY               Japan                      960.11    941.67   967.53   934.25                    950.89            940.34               0.7538
2       EUR                  EU                     1366.56   1339.50  1379.68  1326.38                   1353.03           1338.01               1.0726
3       GBP                  UK                     1531.55   1501.23  1546.26  1486.52                   1516.39           1499.56               1.2021
4       CAD              Canada                      947.51    928.75   956.61   919.65                    938.13            927.72               0.7437
5       CHF               Swiss                     1372.97   1345.79  1386.15  1332.61                   1359.38           1344.29               1.0776
6       HKD            Hongkong                      162.37    159.17   163.93   157.61                    160.77            158.99               0.1274
7       CNY               China                      187.37    183.67   194.79   176.25                    185.52            183.46               0.1471
8       THB            Thailand                       37.80     37.06    38.17    36.69                     37.43             37.01               0.0297
9       IDR           Indonesia                        8.46      8.30     8.88     7.80                      8.38              8.29               0.0066
10      SEK              Sweden                      119.98    117.62   121.17   116.43                    118.80            117.48               0.0942
11      AUD           Austraila                      877.22    859.86   885.65   851.43                    868.54            858.90               0.6885
12      DKK             Denmark                      183.59    179.97   185.41   178.15                    181.78            179.76               0.1441
13      NOK              Norway                      123.22    120.78   124.44   119.56                    122.00            120.65               0.0967
14      SAR               Saudi                      339.59    332.87   353.04   314.38                    336.23            332.50               0.2665
15      KWD              Kuwait                     4167.17   4084.67  4414.73  3837.11                   4125.92           4080.13               3.2706
16      BHD             Bahrain                     3379.34   3312.44  3546.64  3078.22                   3345.89           3308.76               2.6523
17      AED               U.A.E                      346.87    340.01   360.61   321.12                    343.44            339.63               0.2722
18      SGD           Singapore                      959.27    940.29   968.77   930.79                    949.78            939.24               0.7529
19      MYR            Malaysia                           -         -   308.12   281.46                    296.27            292.98               0.2349
20      NZD          NewZealand                      803.45    787.55   811.17   779.83                    795.50            786.67               0.6306
21      TWD              Taiwan                           -         -    44.48    39.46                     41.97             41.50               0.0333
22      PHP         Philippines                       23.40     22.94    25.25    21.78                     23.17             22.91               0.0184
23      VND             Vietnam                        5.42      5.32     6.00     4.74                      5.37              5.31               0.0043
24      PLN              Poland                      288.16    282.46   308.13   262.49                    285.31            282.14               0.2262
25      RUB              Russia                       17.82     17.48    18.88    15.54                     17.65             17.45               0.0140
26      ZAR        South Africa                       72.12     70.70    77.12    65.70                     71.41             70.62               0.0566
27      INR               India                       15.39     15.09    16.45    14.33                     15.24             15.07               0.0121
28      PKR            Pakistan                           -         -        -        -                      4.58              4.53               0.0036
29      BDT          Bangladesh                           -         -        -        -                     11.82             11.69               0.0094
30      EGP               Egypt                           -         -        -        -                     41.77             41.31               0.0331
31      MXN              Mexico                       66.46     65.16    73.04    57.92                     65.81             65.08               0.0522
32      BRL              Brazil                           -         -   272.06   215.69                    245.10            242.38               0.1943
33      BND              Brunei                           -         -   987.77   892.80                    949.78            939.24               0.7529
34      ILS              Israel                           -         -   392.10   334.02                    363.06            359.03               0.2878
35      JOD              Jordan                           -         -  1849.52  1636.12                   1778.39           1758.65               1.4097
36      CZK  the Czech Republic                           -         -    61.22    52.16                     56.69             56.06               0.0449
37      MNT            Mongolia                           -         -        -        -                      0.36              0.36               0.0003
38      FJD                Fiji                           -         -   611.73   521.11                    566.42            560.13               0.4490
39      KHR            Cambodia                           -         -    33.30    28.38                     30.84             30.50               0.0244
40      TRY             Turkiye                       67.63     66.31    72.32    61.62                     66.97             66.23               0.0531
41      HUF             Hungary                        3.46      3.40     3.70     3.16                      3.43              3.39               0.0027
42      QAR               Qatar                           -         -        -        -                    346.12            342.28               0.2744
43      KZT               카자흐스탄                           -         -        -        -                      2.76              2.73               0.0022
44      NPR                  네팔                           -         -        -        -                      9.54              9.43               0.0076
45      XAU             GOLD 1g                    76516.60  75001.42        -        -                  75759.01          75132.42              60.0547
46      XAG           SILVER 1g                           -         -        -        -                    903.23            897.62               0.7160
Answered By: Corralien
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.