Forum Discussion
Anonymous
3 years agoNot applicable
Issue with importing data from web
Hello, I tried to import tables from a web site and it doesn't work. So i tried with another website but now i'm just able to see the tables from the first website (which doesn't work). The t...
Anonymous
3 years agoNot applicable
The source URL is the following : Démographie de la France — Wikipédia (wikipedia.org)
But i tried with many sources and it don't work too...
hokeson
3 years agoMicrosoft Employee
With this code it worked for me without any issues.
let
Source = Web.BrowserContents("https://fr.wikipedia.org/wiki/D%C3%A9mographie_de_la_France"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(1)"}, {"Column2", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(2)"}, {"Column3", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(3)"}, {"Column4", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(4)"}, {"Column5", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(5)"}, {"Column6", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(6)"}, {"Column7", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(7)"}, {"Column8", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(8)"}, {"Column9", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(9)"}, {"Column10", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(10)"}, {"Column11", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(11)"}, {"Column12", "TABLE.wikitable:nth-child(31) > * > TR > :nth-child(12)"}}, [RowSelector="TABLE.wikitable:nth-child(31) > * > TR"]),
#"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"", Int64.Type}, {"Population (1er janvier)", type text}, {"Naissances", type text}, {"Décès", type text}, {"Accroissement naturel", type text}, {"Taux de natalité (pour 1000)", type text}, {"Taux de mortalité (pour 1000)", type text}, {"Accroissement naturel (pour 1000)", type text}, {"Taux de fécondité[Note 1]", type text}, {"Taux de mortalité infantile (pour 1000 naissances)", type text}, {"Espérance de vie (hommes)", type text}, {"Espérance de vie (femmes)", type text}}),
#"Removed Bottom Rows" = Table.RemoveLastN(#"Changed Type",1)
in
#"Removed Bottom Rows"
are you using the most recent version of PBI desktop?
please keep in mind that the page content and structuture may change.
here is the history of the page