Forum Discussion

cjmpetroleum's avatar
cjmpetroleum
Frequent Visitor
1 year ago
Solved

Power query web connection get name from checkbox

I am looking to collect the information highlighted red in the code snippit below using PQ. The table imports just fine with the PQ code, but I can't figure out how to extract the highlighted text. Any ideas? Thanks!!!

 

TARGET CODE

<table class="table table-bordered table-hover1 table-responsive table-condensed">
<caption>
File Results
<a class="btn btn-primary btn-sm" href="/RequestAllSelectedFiles" title="Request Files">Request Files</a>
</caption>
<tbody><tr>
<th class="text-center">
Select
</th>
<th>
File Name
</th>
<th>
File Size
</th>
</tr>
<tr>
<td class="text-center">
<input type="checkbox" onchange="ToggleItemSelected(2878219);" id="CheckboxForFileNumber2878219" name="CheckboxForFileNumber2878219">
</td>
<td class="text-left">
03723592_1988-12-20_DI-SFL-LCL.tif
</td>
<td class="text-center">

<span title="approximately 48 Megabytes">~ 48 MB</span>


</td>
</tr>
<tr>
<td class="text-center">
<input type="checkbox" onchange="ToggleItemSelected(2878218);" id="CheckboxForFileNumber2878218" name="CheckboxForFileNumber2878218">
</td>
<td class="text-left">
03723592_1988-12-20_DI-SFL-LCL.pdf
</td>
<td class="text-center">

<span title="approximately 8 Megabytes">~ 8 MB</span>


</td>
</tr>
<tr>
<td class="text-center">
<input type="checkbox" onchange="ToggleItemSelected(2878217);" id="CheckboxForFileNumber2878217" name="CheckboxForFileNumber2878217">
</td>
<td class="text-left">
03723592_1988-12-20_DIRSV.pdf
</td>
<td class="text-center">

<span title="approximately 1 Megabytes">~ 1 MB</span>


</td>
</tr>

</tbody></table>

 

PQ CODE

let
Source = Web.BrowserContents(MY TARGET WEBSITE),
#"Extracted Table From Html" = Html.Table(Source, {

{"Column1", "TABLE.table.table-bordered.table-hover1.table-responsive.table-condensed > * > TR > :nth-child(1)"},

{"Column2", "TABLE.table.table-bordered.table-hover1.table-responsive.table-condensed > * > TR > :nth-child(2)"},

{"Column3", "TABLE.table.table-bordered.table-hover1.table-responsive.table-condensed > * > TR > :nth-child(3)"}}, [RowSelector="TABLE.table.table-bordered.table-hover1.table-responsive.table-condensed > * > TR"])

  • cjmpetroleum 

     

    Give this a go

     

    let
        Source = Web.BrowserContents("https://www.myonlinetraininghub.com/test/example-table.html"),
        #"Converted to Table" = #table(1, {{Source}}),
        #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each let _list = List.Transform(Text.Split([Column1], "name="), each Text.Middle(_ , 1, Text.PositionOf(_, ">")-2))
    
    in List.LastN(_list , List.Count(_list) -1)),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
        #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Column1"})
    in
        #"Removed Columns"

     

     

    I've copied your <table> code and put it in a file on my site that can be loaded with this query.

     

    Regards

     

    Phil

     

  • Hi cjmpetroleum 

    Just use Text.Split as the below code

     

    let
        Source = Web.BrowserContents("https://www.myonlinetraininghub.com/test/example-table.html"),
        Extract = List.Transform({0..30}, each Text.BetweenDelimiters(Source, "name=""",""">" ,_))
    in
        Extract

2 Replies

  • cjmpetroleum 

     

    Give this a go

     

    let
        Source = Web.BrowserContents("https://www.myonlinetraininghub.com/test/example-table.html"),
        #"Converted to Table" = #table(1, {{Source}}),
        #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each let _list = List.Transform(Text.Split([Column1], "name="), each Text.Middle(_ , 1, Text.PositionOf(_, ">")-2))
    
    in List.LastN(_list , List.Count(_list) -1)),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
        #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Column1"})
    in
        #"Removed Columns"

     

     

    I've copied your <table> code and put it in a file on my site that can be loaded with this query.

     

    Regards

     

    Phil

     

  • Hi cjmpetroleum 

    Just use Text.Split as the below code

     

    let
        Source = Web.BrowserContents("https://www.myonlinetraininghub.com/test/example-table.html"),
        Extract = List.Transform({0..30}, each Text.BetweenDelimiters(Source, "name=""",""">" ,_))
    in
        Extract