Forum Discussion
I need help how to HTML Extrat Multiple links in multiple rows in a Web Page
Olá Janey,
I've reached to split de columns in rows from the example with same transformations. The result is what I want (Image-1). Except that I yet cannot get the urls for the line, that I need to parse to new rows/coluns to get same adicional information (The Yellow boxes). the items in black box is only text.
For Example I need to extrat for same cell's "Column2" the url link for same rows as example:
Each row "Entidades concorrentes", there is a link, I need to get the link's/url's:
"<td data-title="Entidades concorrentes"><a href="/Base4/pt/detalhe/?type=entidades&id=76208">Arquijardim, S.A. (504818384)</a>,<br><a href="/Base4/pt/detalhe/?type=entidades&id=8119">Lusosicó- Construções, S.A. (504870475)</a>,<br><a href="/Base4/pt/detalhe/?type=entidades&id=67630">Penela Terraplanagens - Desaterros e Terraplanagens, Ldª (503954233)</a>,<br><a href="/Base4/pt/detalhe/?type=entidades&id=100117">Tecnorem-Engenharia e Construções, SA (502519533)</a></td>"
Ref: Page: https://www.base.gov.pt/Base4/pt/detalhe/?type=contratos&id=8852980
My Atual Code:
-----------------
let
Source = Web.BrowserContents("https://www.base.gov.pt/Base4/pt/detalhe/?type=contratos&id=8852980"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", ".b-first"}, {"Column2", ".table:nth-child(1) > TBODY:nth-child(1):nth-last-child(1) > TR > :nth-child(2)"}}, [RowSelector=".b-first"]),
#"Replaced Value3" = Table.ReplaceValue(#"Extracted Table From Html","),",")),",Replacer.ReplaceText,{"Column2"}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Replaced Value3", {{"Column2", Splitter.SplitTextByDelimiter("),", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column2"),
#"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter","Portugal",",|Portugal,",Replacer.ReplaceText,{"Column2"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",",,",",",Replacer.ReplaceText,{"Column2"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1",",|P","|P",Replacer.ReplaceText,{"Column2"}),
#"Split Column by Delimiter1" = Table.ExpandListColumn(Table.TransformColumns(#"Replaced Value2", {{"Column2", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column2")
in
#"Split Column by Delimiter1"
-----------------
If possible, I appreciate how to get the links. for each colun that have link.
Best Regards and Thanks.
Manuel mesquita
- v-janeyg-msft4 years ago
Community Support
Hi, manuelmesquita
I don't know what the rules are in the links because I don't understand the language.
I searched for some ways, hope it helps:
Use Power BI Web From Example over multiple URLs
Extracting Data from Complex Web Pages with Power BI - Excelerator BI
use power Query to extract hyperlinks from a web table (microsoft.com)
Best Regards,
Community Support Team _Janey
If this post helps, then please consider Accept it as the solution to help the other members find it more.