Hãy để tôi giải thích & nbsp;@jimmy801 & nbsp;
Trong PowerQuery> Nhận dữ liệu> Web> Dán URL như & NBSP; trong FromWeb [cơ bản]
Tôi làm điều này trong 3 máy tính
1 máy tính xách tay hiển thị hình ảnh bên phải [url thật trong hình tròn màu đỏ hình ảnh bên phải] Nó chỉ có 3 bảng
Nó thường ok & nbsp;
Nhưng khi tôi làm điều đó trong một
2 máy tính xách tay hiển thị trong hình bên trái [bảng HTML] Nó chia dữ liệu trong 20Table & nbsp;
Tôi khó tìm cái bàn thực sự những gì tôi muốn
Tôi không biết chuyện gì đang xảy ra & nbsp;
Bỏ qua nội dung chính
Trình duyệt này không còn được hỗ trợ.
Nâng cấp lên Microsoft Edge để tận dụng các tính năng mới nhất, cập nhật bảo mật và hỗ trợ kỹ thuật.
Html.Table
- Bài báo
- 10/10/2022
- 2 phút để đọc
Trong bài viết này
Cú pháp
Html.Table[html as any, columnNameSelectorPairs as list, optional options as nullable record] as table
Về
Trả về một bảng chứa kết quả chạy các bộ chọn CSS được chỉ định so với html
được cung cấp. Một tham số bản ghi tùy chọn, options
, có thể được cung cấp để chỉ định các thuộc tính bổ sung. Bản ghi có thể chứa các trường sau:
RowSelector
ví dụ 1
Trả về một bảng từ giá trị văn bản HTML mẫu.
Cách sử dụng
Html.Table["JoManager", {{"Name", ".name"}, {"Title", "span"}}, [RowSelector=".name"]]\
Đầu ra
#table[{"Name", "Title"}, {{"Jo", "Manager"}}]
Ví dụ 2
Trích xuất tất cả các HREF từ giá trị văn bản HTML mẫu.
Cách sử dụng
Html.Table["Test", {{"Link", "a", each [Attributes][href]}}]
Đầu ra
#table[{"Link"}, {{"/test.html"}}]
Tôi đã làm điều đó, nhưng nó không nhận ra hàm
Html.Table["JoManager", {{"Name", ".name"}, {"Title", "span"}}, [RowSelector=".name"]]\
0 và hiển thị lỗi bên dưới: Expression.Error: The name 'Html.Table' wasn't recognized. Make sure it's spelled correctly.
Mã M trong Desktop Power BI bên dưới:
let
Source = Web.BrowserContents["//www.forbes.com/global2000/#17a97667335d"],
#"Extracted Table From Html" = Html.Table[Source, {
{"Column1", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column2", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TH:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TD:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column3", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TH:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TH:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TD:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TD:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column4", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TH:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TH:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TH:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TD:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TD:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TD:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column5", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TH:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TH:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TH:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4] + TH:not[[colspan]]:not[[rowspan]]:nth-child[5]:nth-last-child[3], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TD:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TD:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TD:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4] + TD:not[[colspan]]:not[[rowspan]]:nth-child[5]:nth-last-child[3], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column6", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TH:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TH:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TH:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4] + TH:not[[colspan]]:not[[rowspan]]:nth-child[5]:nth-last-child[3] + TH:not[[colspan]]:not[[rowspan]]:nth-child[6]:nth-last-child[2], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TD:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TD:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TD:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4] + TD:not[[colspan]]:not[[rowspan]]:nth-child[5]:nth-last-child[3] + TD:not[[colspan]]:not[[rowspan]]:nth-child[6]:nth-last-child[2], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column7", "TABLE.fbs-table.organization > * > TR > TH:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TH:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TH:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TH:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4] + TH:not[[colspan]]:not[[rowspan]]:nth-child[5]:nth-last-child[3] + TH:not[[colspan]]:not[[rowspan]]:nth-child[6]:nth-last-child[2] + TH:not[[colspan]]:not[[rowspan]]:nth-child[7]:nth-last-child[1], TABLE.fbs-table.organization > * > TR > TD:not[[colspan]]:not[[rowspan]]:nth-child[1]:nth-last-child[7] + TD:not[[colspan]]:not[[rowspan]]:nth-child[2]:nth-last-child[6] + TD:not[[colspan]]:not[[rowspan]]:nth-child[3]:nth-last-child[5] + TD:not[[colspan]]:not[[rowspan]]:nth-child[4]:nth-last-child[4] + TD:not[[colspan]]:not[[rowspan]]:nth-child[5]:nth-last-child[3] + TD:not[[colspan]]:not[[rowspan]]:nth-child[6]:nth-last-child[2] + TD:not[[colspan]]:not[[rowspan]]:nth-child[7]:nth-last-child[1], TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}, {"Column8", "TABLE.fbs-table.organization > * > TR > TD[colspan=""8""]:not[[rowspan]]:nth-child[1]:nth-last-child[1]"}}, [RowSelector="TABLE.fbs-table.organization > * > TR"]],
#"Promoted Headers" = Table.PromoteHeaders[#"Extracted Table From Html", [PromoteAllScalars=true]],
#"Changed Type" = Table.TransformColumnTypes[#"Promoted Headers",{
{"Rank", Int64.Type}, {"Company", type text}, {"Country/Territory", type text}, {"Sales", type text}, {"Profits", type text}, {"Assets", type text}, {"Market Value", type text}, {"Column8", type text}}],
#"Removed Blank Rows" = Table.SelectRows[#"Changed Type", each not List.IsEmpty[List.RemoveMatchingItems[Record.FieldValues[_], {"", null}]]]
in
#"Removed Blank Rows"