Lấy dữ liệu web nhiều trang về file Excel bằng Power Query
Lấy dữ liệu nhiều trang từ web
Trang web www.cophieu68.vn/companylist.php?currentPage=1&o=s&ud=a với số 1 là số thứ tự trang muốn lấy.
Code lấy 20 trang từ 1 đến 20 như sau:
let
InitialWeb = "www.cophieu68.vn/companylist.php?currentPage=",
EndWeb = "&o=s&ud=a",
Pages = {1..20},
Source = List.Transform(Pages, (p)=>
let
Source0 = Web.Page(Web.Contents(InitialWeb & Text.From(p) & EndWeb)){0}[Data]
in Source0),
ColumnList = Table.ColumnNames(Source{0}),
Source1= Table.FromList(Source,Splitter.SplitByNothing()),
Result =Table.ExpandTableColumn(Source1,"Column1",ColumnList)
in
Result
www.giaiphapexcel.com/diendan/threads/l%E1%BA%A5y-d%E1%BB%AF-li%E1%BB%87u-web-nhi%E1%BB%81u-trang-v%E1%BB%81-file-excel-b%E1%BA%B1ng-power-query.158118/
Khóa học SprinGO phù hợp
Ứng dụng AI và Chat GPT trong Quản trị nhân sự
Học xong khóa này, học viên có thể: Hiểu đúng bản chất AI, các nhóm AI phổ biến và cách AI “hoạt động” ở...
Xem khóa học
Bình luận