【问题标题】:how to load all date (fx rates, volumes) from an xml file如何从 xml 文件加载所有日期(外汇汇率、交易量)
【发布时间】:2020-02-17 07:27:39
【问题描述】:

在这个网站上有一个 xls 文件实际上是一个 xml 文件: https://www.bom.mu/markets/foreign-exchange/fx-dealt?field_dealing_date_value%5Bvalue%5D%5Bdate%5D=01-01-2010 您可以通过单击 xls 第二个按钮来获取它。 如何获取数据:Rs/USD、Rs/EUR、Rs/GBP 以及每个日期的总购买量(以美元计价)和总销售额(以美元计价)?

谢谢。

示例:

    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      </head>
      <body>
        <table>
        <thead><tr><th></th><th></th></tr></thead>    
    <tbody> <tr class="odd"><td>FOREIGN EXCHANGE MARKET: <b>Friday, 14 February 2020</b></td><td>                <p>Transactions above USD20,000 or equivalent in other currencies as reported by banks and Foreign Exchange Dealers: </p>
    <div class="table-responsive">
<table class="views-table cols-3 table table-hover table-striped">
     <thead>
            <tr>
                  <th class="views-field"></th>
                  <th class="views-field">Weighted Dealt Rates</th>
                  <th class="views-field"></th>
            </tr>
    </thead>
    <tbody>
            <tr class="odd views-row-first">
                  <td class="views-field"></td>
                  <td class="views-field">Buying</td>
                  <td class="views-field">Selling</td>
            </tr>
            <tr class="odd views-row-first">
                  <td class="views-field">Rs/USD</td>
                  <td class="views-field">37.2313</td>
                  <td class="views-field">37.4248</td>
          </tr>
          <tr class="even">
                  <td class="views-field">Rs/EUR</td>
                  <td class="views-field">40.2937</td>
                  <td class="views-field">40.5857</td>
          </tr>
      <tr class="odd views-row-first">
                  <td class="views-field">Rs/GBP</td>
                  <td class="views-field">48.5692</td>
                  <td class="views-field">48.8421</td>
          </tr>
      </tbody>
</table>

<table class="views-table cols-3 table table-hover table-striped table-amount-dealt">
     <thead>
            <tr>
                  <th class="views-field"></th>
                  <th class="views-field"></th>
                  <th class="views-field">Amount (USD Equivalent)</th>
            </tr>
    </thead>
    <tbody>

            <tr class="odd views-row-first">
                  <td class="views-field">Total Purchases</td>
                  <td class="views-field"></td>
                  <td class="views-field">18,969,525</td>
          </tr>
          <tr class="odd views-row-first">
                 <td class="views-field">(out of which forward purchases)</td>
                 <td class="views-field"></td>
                  <td class="views-field">895,278</td>
          </tr>
          <tr class="even">
                  <td class="views-field">Total Sales</td>
                  <td class="views-field"></td>
                  <td class="views-field">16,465,160</td>
          </tr>
          <tr class="odd">
                  <td class="views-field">(out of which forward sales)</td>
                  <td class="views-field"></td>
                  <td class="views-field">636,701</td>
           </tr>
      </tbody>
</table>

【问题讨论】:

  • 添加你尝试过的代码。
  • ex_data = pd.read_html('fx_dealt_rates.xls')
  • 问题出在哪里?
  • 我不知道如何获取每个日期的数据:>Rs/USD:37.2313 和 37.4248。以及其他卢比/欧元和卢比/英镑以及总购买和总销售额

标签: python xml parsing web-scraping


【解决方案1】:

【讨论】:

  • 是的,但我不知道如何修改解析器以提取我想要的数据。
猜你喜欢
  • 2018-09-04
  • 1970-01-01
  • 2017-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多