使用BeautifulSoup Python提取ids的内容

2024-10-03 21:28:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一些html页面,应该有1个表,一些行和2个列,我正在尝试将它们转换为cvs表。我想循环遍历行并获取列,但是我无法仅获取ID中的部分(例如 id="(-) Additional deductions of AT1 Capital due to Article 3 CRR"). Is there a way just to extract the content of id for each row?

代码

import requests
from bs4 import BeautifulSoup
import pandas as pd

definitions=[]

file = '/Users/tom/Downloads/Capitalresourceitemlevel1.html'

soup = BeautifulSoup(open(file), "html.parser")

table = soup.find_all('table')

for i in table:
    rows = i.find_all('tr')

for i in rows:
    row_tds = i.find_all('td')
    if len(row_tds) == 2:
        definitions.append((row_tds[0].text, row_tds[1].text))
    
with open('output.csv', 'w') as f:
    for line in definitions:
        f.write(','.join(line))
        f.write('\n')

html

<html xmlns="http://www.w3.org/1999/xhtml">
<style>
        /*
        Colors
        #ffffff
        #333333
        #f2f2f2;
        #dddddd;
        */


        @media all
        {
        html
        {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 14px;
        line-height: 1.428571429;
        color: #333333;
        margin: 0;
        background-color: #ffffff;
        }

        header
        {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 36px;
        border-top: 4px solid transparent;
        border-right: 4px solid transparent;
        border-left: 4px solid transparent;
        border-bottom: 2px solid #f2f2f2;
        }

        header:after
        {
        content: "Style: technical";
        font-size: 22px;
        }

        body
        {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 11px;
        line-height: 1.428571429;
        color: #333333;
        margin: 20;
        background-color: #ffffff;
        }

        .footer
        {
        page-break-after: always;
        }

        @page:right{
        @bottom-left {
        margin: 10pt 0 30pt 0;
        border-top: .25pt solid #666;
        content: "My book";
        font-size: 9pt;
        color: #333;
        }
        }

        li span
        {
        font-size: 18px;
        }

        h1
        {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 24px;
        font-weight: normal;
        }

        a:focus=""
        {
        outline: thin dotted;
        }

        a:link
        {
        text-decoration: none;
        }

        a:active,
        a:hover
        {
        text-decoration: underline;
        outline: 0;
        }

        table {
        border-collapse: collapse;
        border-spacing: 0;
        border: 2px solid transparent;
        width: 99%;
        margin-left:0px;
        margin-right:0px;
        margin-bottom: 50px;
        }


        caption
        {
        caption-side: top;
        }

        th
        {
        text-align: left;
        height: 50px;
        border-bottom: 1px solid #ddd;
        font-weight: normal;
        font-size: 18px;
        white-space: normal;
        word-wrap:break-word;
        }


        td
        {
        text-align: left;
        padding: 8px;
        border-bottom: 1px solid #ddd;
        }

        #descriptionvalue
        {
        margin-top: 20px;
        margin-bottom: 50px;
        font-size: 18px;
        }


        #Welcome
        {
        font-size: 18px;
        height:95%;
        }


        div.FalseTableHeader
        {
        border: 2px solid #dddddd;
        border-bottom: 0px solid transparent;
        border-top-right-radius: 0.6em;
        border-top-left-radius: 0.6em;
        background-color: #f2f2f2;
        margin-bottom: 0px;
        height: 50px;
        /*width: 98%;*/
        position: relative
        }

        p.FalseTableHeader
        {
        font-size: 18px;
        padding-top: 0px;
        padding-bottom: 0px;
        margin: 0;
        position: absolute;
        top: 50%;
        transform: translate(0,-70);
        }

        .TableContainer
        {
        margin-top: 0px;
        border: 2px solid #dddddd;
        border-bottom-right-radius: 0.6em;
        border-bottom-left-radius: 0.6em;
        overflow-x: auto;

        }
        #breadcrumbs
        {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 14px;
        font-style: normal;
        margin-bottom: 20px;
        border-top-left-radius: 0.6em;
        }

        .float_center {
        float: right;
        position: relative;
        left: -50%;
        text-align: left;
        }

        .float_center &gt; .child {
        position: relative;
        left: 50%;
        }

        .footer
        {
        display: block;
        background-color: #f2f2f2;
        border: 2px solid #dddddd;
        font-size: 14px;
        height: 22px;
        padding: 10px 15px;
        margin-top: 20px;
        margin-left:0px;
        width: 98%;
        }

        .footer  .copyright
        {
        float:left;
        padding-left: 0px;
        }

        .footer  .date
        {
        float:right;
        padding-right: 0px;
        }


        }




        @media screen
        {
        }




        @media print
        {

        @page {size: A4;}
        .footer {page-break-after: always;}
        #Welcome {font-size: 18px;  height:auto;}

        }
      </style>
<head>
<title>Bank of England</title>
</head>
<header>
<img class="site_logo" src="data:image/gif;base64,R0lGODlhPwE/APcAAAMDAwICAgUFBSoqKq6uru3t7dLS0g0NDevr69jY2OLi4igoKMrKygQEBAEBAf39/W9vb5aWlvz8/AoKCrCwsKWlpYiIiK2trf7+/gYGBuXl5WxsbPn5+SUlJfr6+hoaGvHx8fv7+9HR0cbGxpubm5mZmRMTE+fn57KysuHh4Wtra+Tk5Nvb2/Ly8gcHB7u7u9fX14uLi/T09CIiIu7u7tPT0wsLC8nJyaKiooaGhuzs7A4ODuDg4NTU1Pb29rW1tb29venp6XV1dfj4+BEREdra2t/f38fHx9bW1hkZGT09PfX19TExMSYmJh0dHdnZ2RwcHBUVFRAQEM7Ozr6+viAgICEhIQwMDGRkZOrq6jAwMN7e3i4uLnFxce/v78jIyBsbG5iYmFVVVSMjI6CgoLGxsXp6ehISEmdnZxQUFOPj4zw8PEZGRk1NTTQ0NB8fHz4+PtXV1aysrMzMzCQkJMDAwMHBwcLCws3NzYmJiZ6enqioqHx8fHJycpGRkc/Pzz8/P35+flpaWl1dXUNDQxcXF+jo6IGBgcPDw7S0tMTExCkpKba2tre3t/Dw8C8vLx4eHsXFxQgICHd3d6ampicnJ05OTkRERLOzszU1NdDQ0K+vr/Pz8+bm5qSkpJ+fn4WFhdzc3N3d3X19faurq3BwcGNjY5OTk1JSUlhYWEVFRQ8PD2VlZVBQUFtbW0FBQXl5eXNzc1FRUY2Njbq6upycnISEhCwsLHZ2dhYWFoCAgDc3N5qamoyMjHt7e6Ojo0pKShgYGG1tbWZmZr+/v09PT1NTU0dHRzo6Orm5uff3939/f3h4eFdXV19fX5WVlTk5OUJCQry8vMvLy0BAQG5uboeHh0tLS6GhoVxcXJ2dnUhISLi4uGFhYaqqqlZWVmJiYmlpaZSUlFlZWTIyMqm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fUIAyb8Ax+gAZcgA7GoAKnPgWmwA5yEAItUAKkYAcm8Aqu1veszxGOoAoNEDv/AEKG4AduMA9zYAvnAwr0UAy4sAH6YAn1IAi4cAtcsA6XIASDIAgvgAAYQAOpIAWpIAQ6fQZMkAKtn/0ekQX9//pXDBAI95AJUqAOzCAEFPCjn1AAhjAEITBDQJACeHADLTA1BoIIsdgL3XAej3AEjAAQNriw+FfQ4EGECRUuZNjQ4UOIESVOpFjR4kWMGTPqKOZvEgsh/vwtGCTMl65Ja9p1EQIBghkzgXDFFNKnS7VSupapKyRSCI0S/qgZ0VjU6FGkSZUuZdq0oAxc/tgkuMHGH7t3cxDZyQGqBBAqVICMJQuWCjFENyoQ8gePSid+/kwhcFrX7l28efUifVBBShJxBS5oqaKOAAdOWNJBvGOqyQBeQSiNkdRuyF7MmTVv5oz0SbMr7DBpKKfqQxJUhISIQgBCho8lLQqoURQm1cCMD8i0dZKmxIaqP52FDydevPMFJQDYkTAS51kbLrmIOGEC6FK0XXRypVmgKs8UNeWQ+WPy6YFx9OnVr9co4RebABPMeYNR5AapWczCYaknJA+lEZ54AoUNzvBHiRJaYG9BBht0sKAQiLlHC39cQMYZez5B4QUqXkgEhxxMAeQAf5oQppElH lRxRRaFC2IEP8xhgggXGmjABQEEyGCHW1yJoY4VWhRySCLx8sCLThKI5AVuXlAkDg1o4KBIKqusMiAAOw=="/>
<div>Stress Test Data Framework Dictionary 2021: Version 02</div>
</header>
<body>
<div></div>
<p id="breadcrumbs">&gt;<a href="..\..\..\Home.html" xmlns="">Home</a>&gt;<a href="..\..\..\Contents\Contents.html" xmlns="">Contents</a>&gt;<a href="..\..\..\Contents\Enumerations\Enumerations.html" xmlns="">Enumerations</a>&gt;<a href="..\..\..\Contents\Enumerations\Capitalresourceitemlevel1\Capitalresourceitemlevel1.html" xmlns="">Capitalresourceitemlevel1</a></p>
<h1 id="..\..\..\Contents\Enumerations\Capitalresourceitemlevel1\Capitalresourceitemlevel1.html" xmlns="">Capitalresourceitemlevel1</h1>
<p class="TableContainer" xmlns="">
<table id="table1">
<tr>
<th>Enumeration</th>
<th>Definition</th>
</tr>
<tr>
<td id="(-) Additional deductions of AT1 Capital due to Article 3 CRR" text="">(-) Additional deductions of AT1 Capital due to Article 3 CRR</td>
<td id="" text="">COREP CA1 ID1.1.2.11</td>
</tr>
<tr>
<td id="(-) Additional deductions of CET1 Capital due to Article 3 CRR" text="">(-) Additional deductions of CET1 Capital due to Article 3 CRR</td>
<td id="" text="">COREP CA1 ID1.1.1.27</td>
</tr>
<tr>
<td id="(-) Additional deductions of T2 Capital due to Article 3 CRR" text="">(-) Additional deductions of T2 Capital due to Article 3 CRR</td>
<td id="" text="">COREP CA1 ID1.2.12</td>
</tr>
<tr>
<td id="(-) Amount exceeding the 17.65% threshold" text="">(-) Amount exceeding the 17.65% threshold</td>
<td id="" text="">COREP CA1 ID1.1.1.25</td>
</tr>
<tr>
<td id="(-) AT1 instruments of financial sector entities where the institution does not have a significant investment" text="">(-) AT1 instruments of financial sector entities where the institution does not have a significant investment</td>
<td id="" text="">COREP CA1 ID1.1.2.6</td>
</tr>
<tr>
<td id="(-) AT1 instruments of financial sector entities where the institution has a significant investment" text="">(-) AT1 instruments of financial sector entities where the institution has a significant investment</td>
<td id="" text="">COREP CA1 ID1.1.2.7</td>
</tr>
<tr>
<td id="(-) CET1 instruments of financial sector entities where the institution does not have a significant investment" text="">(-) CET1 instruments of financial sector entities where the institution does not have a significant investment</td>
<td id="" text="">COREP CA1 ID1.1.1.22</td>
</tr>
<tr>
<td id="(-) CET1 instruments of financial sector entities where the institution has a significant investment" text="">(-) CET1 instruments of financial sector entities where the institution has a significant investment</td>
<td id="" text="">COREP CA1 ID1.1.1.24</td>
</tr>
<tr>
<td id="(-) Deductible deferred tax assets that rely on future profitability and arise from temporary differences" text="">(-) Deductible deferred tax assets that rely on future profitability and arise from temporary differences</td>
<td id="" text="">COREP CA1 ID1.1.1.23</td>
</tr>
<tr>
<td id="(-) Deferred tax assets that rely on future profitability and do not arise from temporary differences net of associated tax liabilities" text="">(-) Deferred tax assets that rely on future profitability and do not arise from temporary differences net of associated tax liabilities</td>
<td id="" text="">COREP CA1 ID1.1.1.12</td>
</tr>
<tr>
<td id="(-) Equity exposures under an internal models approach which can alternatively be subject to a 1250% risk weight" text="">(-) Equity exposures under an internal models approach which can alternatively be subject to a 1250% risk weight</td>
<td id="" text="">COREP CA1 ID1.1.1.21</td>
</tr>
<tr>
<td id="(-) Excess of deduction from AT1 items over AT1 Capital" text="">(-) Excess of deduction from AT1 items over AT1 Capital</td>
<td id="" text="">COREP CA1 ID1.1.1.16</td>
</tr>
<tr>
<td id="(-) Excess of deduction from T2 items over T2 Capital" text="">(-) Excess of deduction from T2 items over T2 Capital</td>
<td id="" text="">COREP CA1 ID1.1.2.8</td>
</tr>
<tr>
<td id="(-) Free deliveries which can alternatively be subject to a 1250% risk weight" text="">(-) Free deliveries which can alternatively be subject to a 1250% risk weight</td>
<td id="" text="">COREP CA1 ID1.1.1.19</td>
</tr>
<tr>
<td id="(-) Goodwill" text="">(-) Goodwill</td>
<td id="" text="">COREP CA1 ID1.1.1.10</td>
</tr>
<tr>
<td id="(-) IRB shortfall of credit risk adjustments to expected losses" text="">(-) IRB shortfall of credit risk adjustments to expected losses</td>
<td id="" text="">COREP CA1 ID1.1.1.13</td>
</tr>
<tr>
<td id="(-) Other intangible assets" text="">(-) Other intangible assets</td>
<td id="" text="">COREP CA1 ID1.1.1.11</td>
</tr>
<tr>
<td id="(-) Positions in a basket for which an institution cannot determine the risk weight under the IRB approach, and can alternatively be subject to a 1250% risk weight" text="">(-) Positions in a basket for which an institution cannot determine the risk weight under the IRB approach, and can alternatively be subject to a 1250% risk weight</td>
<td id="" text="">COREP CA1 ID1.1.1.20</td>
</tr>
<tr>
<td id="(-) Qualifying holdings outside the financial sector which can alternatively be subject to a 1250% risk weight" text="">(-) Qualifying holdings outside the financial sector which can alternatively be subject to a 1250% risk weight</td>
<td id="" text="">COREP CA1 ID1.1.1.17</td>
</tr>
<tr>
<td id="(-) Reciprocal cross holdings in AT1 Capital" text="">(-) Reciprocal cross holdings in AT1 Capital</td>
<td id="" text="">COREP CA1 ID1.1.2.5</td>
</tr>
<tr>
<td id="(-) Reciprocal cross holdings in CET1 Capital" text="">(-) Reciprocal cross holdings in CET1 Capital</td>
<td id="" text="">COREP CA1 ID1.1.1.15</td>
</tr>
<tr>
<td id="(-) Reciprocal cross holdings in T2 Capital" text="">(-) Reciprocal cross holdings in T2 Capital</td>
<td id="" text="">COREP CA1 ID1.2.7</td>
</tr>
<tr>
<td id="(-) Securitisation positions which can alternatively be subject to a 1250% risk weight" text="">(-) Securitisation positions which can alternatively be subject to a 1250% risk weight</td>
<td id="" text="">COREP CA1 ID1.1.1.18</td>
</tr>
<tr>
<td id="(-) T2 instruments of financial sector entities where the institution does not have a significant investment" text="">(-) T2 instruments of financial sector entities where the institution does not have a significant investment</td>
<td id="" text="">COREP CA1 ID1.2.8</td>
</tr>
<tr>
<td id="(-) T2 instruments of financial sector entities where the institution has a significant investment" text="">(-) T2 instruments of financial sector entities where the institution has a significant investment</td>
<td id="" text="">COREP CA1 ID1.2.9</td>
</tr>
<tr>
<td id="(-)Defined benefit pension fund assets" text="">(-)Defined benefit pension fund assets</td>
<td id="" text="">COREP CA1 ID 1.1.1.14</td>
</tr>
<tr>
<td id="10% CET1 threshold" text="">10% CET1 threshold</td>
<td id="" text="">COREP CA4 ID9</td>
</tr>
<tr>
<td id="17.65% CET1 threshold" text="">17.65% CET1 threshold</td>
<td id="" text="">COREP CA4 ID10</td>
</tr>
<tr>
<td id="Accumulated other comprehensive income" text="">Accumulated other comprehensive income</td>
<td id="" text="">COREP CA1 ID1.1.1.3</td>
</tr>
<tr>
<td id="Additional Tier 1 Capital" text="">Additional Tier 1 Capital</td>
<td id="" text="">COREP CA1 ID1.1.2</td>
</tr>
<tr>
<td id="Adjustments to CET1 due to prudential filters" text="">Adjustments to CET1 due to prudential filters</td>
<td id="" text="">COREP CA1 ID1.1.1.9</td>
</tr>
<tr>
<td id="Adjustments to total own funds" text="">Adjustments to total own funds</td>
<td id="" text="">
</td>
</tr>
<tr>
<td id="AT1 capital elements or deductions - other" text="">AT1 capital elements or deductions - other</td>
<td id="" text="">COREP CA1 ID1.1.2.12</td>
</tr>
<tr>
<td id="Capital instruments and subordinated loans eligible as T2 Capital" text="">Capital instruments and subordinated loans eligible as T2 Capital</td>
<td id="" text="">COREP CA1 ID1.2.1</td>
</tr>
<tr>
<td id="Capital instruments eligible as AT1 Capital" text="">Capital instruments eligible as AT1 Capital</td>
<td id="" text="">COREP CA1 ID1.1.2.1</td>
</tr>
</table>
</p>
<div class="footer" xmlns=""><span class="copyright">
        Copyright: Bank Of England</span><span class="float_center">
        PageNo:298</span><span class="date">
        Created: 2021-01-18 00:00:00</span></div>
</body>
<footer></footer>
</html>

Tags: ofthetotextidsizetrtd
1条回答
网友
1楼 · 发布于 2024-10-03 21:28:09

将最后一行替换为以下内容之一如何:

  • definitions.append([td.text for td in i.find_all('td')])
  • definitions.append([td['id'] for td in i.find_all('td')])(根据贾斯汀·埃泽奎尔的评论)

这将获得每个变量的textid

按评论编辑:
这就是您可以做到的,基本上您需要在每个td中保存两个项目的文本元组。 第二部分是将其写入文件的一种方法

for i in rows:
    row_tds = i.find_all('td')
    if len(row_tds) == 2:
        definitions.append((row_tds[0].text, row_tds[1].text))
    
with open('output.csv', 'w') as f:
    for line in definitions:
        f.write(','.join(line))
        f.write('\n')

相关问题 更多 >