简体   繁体   English

无法使用 `read_html 获取特定表

[英]Impossible to get specific table with `read_html

I am trying to access a table with read_html function ( URL ).我正在尝试使用read_html函数( URL )访问表。

My problem is that it seems that read_html does not find my table whereas it exists.我的问题是read_html似乎没有找到我的表,而它存在。 I don't know why except that the table I want to read has the same attribute than an other one.我不知道为什么,除了我要阅读的表格与另一个表格具有相同的属性。

I did first :我先做了:

url = 'https://geco.amf-france.org/Bio/res_part.aspx?NomProd=&OrderBy=&OrderBySens=&NumAgr=&CodeISIN=&NomSoc=&selectNRJ=OPCVM&ClassProd=0&TypeProd=&npos='
df = pd.read_html(url)
df

it returns 3 df store in df[0], df 1 and df[3] but none is the main table that I saw.它在 df[0]、df 1和 df[3] 中返回 3 个 df 存储,但没有一个是我看到的主表。 It is just little table ie and not the 'big' one as in the image :它只是一张小桌子,而不是图片中的“大”桌子:

[                                                   0
 0  Recherche Liste  Vendredi 2 octobre 2020  Prod...,
                    0             1                     2  \
 0          Recherche     Recherche             Recherche   
 1  Produit financier  Gestionnaire  Valeurs liquidatives   
 
                                3        4                       5  \
 0                      Recherche    Liste                   Liste   
 1  Associations Professionnelles  Encours  Gestionnaires agréés   
 
                                        6                        7  
 0                                  Liste  Vendredi 2 octobre 2020  
 1  Gestionnaires de l'EEE - Passeport IN   Recherche Documentaire  ,
                    0   1                         2      3
 0   Code ISIN part : NaN          Nom de Produit :    NaN
 1  N° d'agrément : NaN  Classification produit :    NaN
 2           Nom SG : NaN       Régime juridique :  OPCVM] 

I also tried :我也试过:

df = pd.read_html(url, attrs = {'class' : 'ctcoltableresult2'})
df

but it returns nothing但它什么都不返回

我想得到的主表

Any ideas?有任何想法吗?

It looks like if you specify the falvor as bs4 it works.看起来如果您将 falvor 指定为 bs4 就可以了。 I also added attrs to only get the 'big' table.我还添加了 attrs 以获取“大”表。

url = 'https://geco.amf-france.org/Bio/res_part.aspx?NomProd=&OrderBy=&OrderBySens=&NumAgr=&CodeISIN=&NomSoc=&selectNRJ=OPCVM&ClassProd=0&TypeProd=&npos='
df = pd.read_html(url, flavor='bs4', attrs={'class':'ctcoltableresult2'})
df

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM