【发布时间】:2020-04-15 14:59:09
【问题描述】:
我已经从https://www.asx.com.au/asx/statistics/prevBusDayAnns.do 抓取了 HTML 表格。我已将此表放入熊猫数据框中。我还为名为“Match”的数据框创建了另一列,如果“ASX Code”=“SPL”,它会显示 1。如果您查看网站,您会看到标题是 PDF 文件的标题可以下载。如果“匹配”列 = 1,我想下载文件。这可能吗?硒?
我的代码:
import pandas as pd
dfs = pd.read_html('https://www.asx.com.au/asx/statistics/prevBusDayAnns.do')
for df in dfs:
df.loc[df['ASX Code'] == 'SPL', 'Match'] = "1"
df.loc[df['ASX Code'] != 'SPL', 'Match'] = "0"
print(df)
数据框:
ASX Code Date Price sens. Headline Match
0 SPL 15/04/2020 7:25 PM NaN SPL7013 shows significant activity against cor... 1
1 LSH 15/04/2020 7:19 PM NaN Change of Director's Interest Notice 2 pages... 0
2 PSQ 15/04/2020 7:14 PM NaN PSQ Implements Dividend Reinvestment Plan 25 ... 0
3 TGN 15/04/2020 7:11 PM NaN March Quarterly Report and Appendix 5B 24 pa... 0
4 GRR 15/04/2020 6:49 PM NaN Change of Director's Interest Notice 3 pages... 0
【问题讨论】:
-
为什么需要熊猫?如果你想根据
ASX Code下载 pdf,你只能使用 selenium 来完成 -
我不需要它,我只是为了方便使用它。我该怎么做?