晚上好,我使用BeautifulSoup从网站中提取一些数据如下:
from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
soup = BeautifulSoup(urlopen('http://www.fsa.gov.uk/about/media/facts/fines/2002'))
table = soup.findAll('table', attrs={ "class" : "table-horizontal-line"})
print table
Run Code Online (Sandbox Code Playgroud)
这给出了以下输出:
[<table width="70%" class="table-horizontal-line">
<tr>
<th>Amount</th>
<th>Company or person fined</th>
<th>Date</th>
<th>What was the fine for?</th>
<th>Compensation</th>
</tr>
<tr>
<td><a name="_Hlk74714257" id="_Hlk74714257"> </a>£4,000,000</td>
<td><a href="/pages/library/communication/pr/2002/124.shtml">Credit Suisse First Boston International </a></td>
<td>19/12/02</td>
<td>Attempting to mislead the Japanese regulatory and tax authorities</td>
<td> </td>
</tr>
<tr>
<td>£750,000</td>
<td><a href="/pages/library/communication/pr/2002/123.shtml">Royal Bank of Scotland plc</a></td>
<td>17/12/02</td>
<td>Breaches of money laundering rules</td>
<td> </td>
</tr>
<tr>
<td>£1,000,000</td> …Run Code Online (Sandbox Code Playgroud) 我需要一些帮助,我有一个包含地址字段的 CSV 文件,无论谁将数据输入到原始数据库中,都使用逗号来分隔地址的不同部分 - 例如:
公园街 5 室
当我尝试使用 CSV 文件时,它会将这个条目视为两个单独的字段,而实际上它是一个字段。我已经使用 Python 去除了逗号之间的逗号,因为很容易将它们与实际应该在那里的逗号区分开来,但是这个问题让我很难过。
任何帮助将不胜感激。
谢谢。