I am polling a Canadian web site that has public demographic data for all of the Schools in the province of Ontario. You reach the page I want, by including the unique school identifier as a parameter value in the URL.
https://www.app.edu.gov.on.ca/eng/sift/schoolProfileSec.asp?SCH_NUMBER=916293. I have a list of the schools with this identifying number and I want to create a function that will scroll through this list and pull the HTML table from the page for each school.
This is the code for the function
(Mident as text) =>
let
Source = Web.BrowserContents(“https://www.app.edu.gov.on.ca/eng/sift/schoolProfileSec.asp?SCH_NUMBER=” & Mident),
#“Extracted Table From Html” = Html.Table(Source, {{“Column1”, “DIV.row:nth-child(13) > TABLE > * > TR > TD[rowspan=”“2"”]:not([colspan]):nth-child(1):nth-last-child(3), DIV.row:nth-child(13) > TABLE > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(4)“}, {“Column2”, “DIV.row:nth-child(13) > TABLE > * > TR > TD[rowspan=”“2"”]:not([colspan]):nth-child(1):nth-last-child(3) + TH[rowspan=”“2"”]:not([colspan]):nth-child(2):nth-last-child(2), DIV.row:nth-child(13) > TABLE > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(4) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(3)“}, {“Column3”, “DIV.row:nth-child(13) > TABLE > * > TR > TD[rowspan=”“2"”]:not([colspan]):nth-child(1):nth-last-child(3) + TH[rowspan=”“2"”]:not([colspan]):nth-child(2):nth-last-child(2) + TH[colspan=““2"”]:not([rowspan]):nth-child(3):nth-last-child(1), DIV.row:nth-child(13) > TABLE > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2), DIV.row:nth-child(13) > TABLE > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(4) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(3) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(2)”}, {“Column4”, “DIV.row:nth-child(13) > TABLE > * > TR > TD[rowspan=”“2"”]:not([colspan]):nth-child(1):nth-last-child(3) + TH[rowspan=““2"”]:not([colspan]):nth-child(2):nth-last-child(2) + TH[colspan=”“2"”]:not([rowspan]):nth-child(3):nth-last-child(1), DIV.row:nth-child(13) > TABLE > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2) + TH:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(1), DIV.row:nth-child(13) > TABLE > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(4) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(3) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(2) + TD:not([colspan]):not([rowspan]):nth-child(4):nth-last-child(1)"}}, [RowSelector=“DIV.row:nth-child(13) > TABLE > * > TR”]),
#“Changed Type” = Table.TransformColumnTypes(#“Extracted Table From Html”,{{“Column1”, type text}, {“Column2”, type text}, {“Column3”, type text}, {“Column4”, type text}}),
#“Renamed Columns” = Table.RenameColumns(#“Changed Type”,{{“Column2”, “Column2 1”}})
in
#“Renamed Columns”
I can connect to the web page and pull the data for individual schools but as soon as I create the custom function and add it to a table that has 1 column (Mident) with all of the school identifiers, and save my changes the module the system hangs with a message “Creating connection in model”. This lasts long enough that the system times out.
The process seems pretty straight forward and I can not figure out how to get rid of the error around creating the connection in the model.
Has anyone seen this issue and found a resolution for it ??
List of Schools.xlsx (11.2 KB)