Forum Discussion
Mekist
1 year agoHelper III
Retrieving data with HTML
Hello I get dividend information of companies with the following code, How can I get it using html method
Hisse = "AKSA",
KaynakHam = Web.Page(Web.Contents("https://www.isyatirim.com.tr/tr-tr/analiz/hisse/Sayfalar/sirket-karti.aspx?hisse=" & Hisse)),
Kaynak = Table.Buffer(KaynakHam),
Tablolar = Kaynak[Data],
IstenenTablo = List.First(
List.Select(
Tablolar,
each List.Contains(Table.ColumnNames(_), "Kod") and List.Contains(Table.ColumnNames(_), "Dağ. Tarihi")
),
null
),
SonucTablo = if IstenenTablo <> null then
let
#"Tarih Dönüştürüldü" = Table.TransformColumns(
IstenenTablo,
{{"Dağ. Tarihi", each try Date.FromText(_, "tr-TR") otherwise null, type date}}
),
#"Filtrelenmiş Satırlar" = Table.SelectRows(
#"Tarih Dönüştürüldü",
each [Dağ. Tarihi] >= #date(2024, 1, 1)
),
#"Tekil Satırlar" = Table.Distinct(#"Filtrelenmiş Satırlar")
in
#"Tekil Satırlar"
else
null
in
SonucTablo
13 Replies
- lbendlinSuper User
Use Web.BrowserContents. Indicate which of the DOM elements you want to grab.
let Source = Web.BrowserContents("https://www.isyatirim.com.tr/tr-tr/analiz/hisse/Sayfalar/sirket-karti.aspx?hisse=AKSA"), #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV.tab-item:nth-child(1) > DIV.row > DIV.col-md-6.col-sm-12.col-xs-12 > TABLE.chartlist > * > TR > :nth-child(1)"}, {"Column2", "DIV.tab-item:nth-child(1) > DIV.row > DIV.col-md-6.col-sm-12.col-xs-12 > TABLE.chartlist > * > TR > :nth-child(2)"}, {"Column3", "DIV.tab-item:nth-child(1) > DIV.row > DIV.col-md-6.col-sm-12.col-xs-12 > TABLE.chartlist > * > TR > :nth-child(3)"}, {"Column4", "DIV.tab-item:nth-child(1) > DIV.row > DIV.col-md-6.col-sm-12.col-xs-12 > TABLE.chartlist > * > TR > :nth-child(4)"}}, [RowSelector="DIV.tab-item:nth-child(1) > DIV.row > DIV.col-md-6.col-sm-12.col-xs-12 > TABLE.chartlist > * > TR"]), #"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]), #"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"", "Item"}}) in #"Renamed Columns"For example the above grabs the first table.
- MekistHelper III
It's not a table number, it's a table number. className "temettugercekvarBody hepsi" will Varbody all" can we add this
- lbendlinSuper User
Table 15
let Source = Web.BrowserContents("https://www.isyatirim.com.tr/tr-tr/analiz/hisse/Sayfalar/sirket-karti.aspx?hisse=AKSA"), #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column2", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column3", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7) + TH[colspan=""1""][rowspan=""1""]:nth-child(3):nth-last-child(6), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(6), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column4", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7) + TH[colspan=""1""][rowspan=""1""]:nth-child(3):nth-last-child(6) + TH[colspan=""1""][rowspan=""1""]:nth-child(4):nth-last-child(5), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(6) + TD:not([colspan]):not([rowspan]):nth-child(4):nth-last-child(5), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column5", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7) + TH[colspan=""1""][rowspan=""1""]:nth-child(3):nth-last-child(6) + TH[colspan=""1""][rowspan=""1""]:nth-child(4):nth-last-child(5) + TH[colspan=""1""][rowspan=""1""]:nth-child(5):nth-last-child(4), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(6) + TD:not([colspan]):not([rowspan]):nth-child(4):nth-last-child(5) + TD:not([colspan]):not([rowspan]):nth-child(5):nth-last-child(4), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column6", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7) + TH[colspan=""1""][rowspan=""1""]:nth-child(3):nth-last-child(6) + TH[colspan=""1""][rowspan=""1""]:nth-child(4):nth-last-child(5) + TH[colspan=""1""][rowspan=""1""]:nth-child(5):nth-last-child(4) + TH[colspan=""1""][rowspan=""1""]:nth-child(6):nth-last-child(3), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(6) + TD:not([colspan]):not([rowspan]):nth-child(4):nth-last-child(5) + TD:not([colspan]):not([rowspan]):nth-child(5):nth-last-child(4) + TD:not([colspan]):not([rowspan]):nth-child(6):nth-last-child(3), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column7", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7) + TH[colspan=""1""][rowspan=""1""]:nth-child(3):nth-last-child(6) + TH[colspan=""1""][rowspan=""1""]:nth-child(4):nth-last-child(5) + TH[colspan=""1""][rowspan=""1""]:nth-child(5):nth-last-child(4) + TH[colspan=""1""][rowspan=""1""]:nth-child(6):nth-last-child(3) + TH[colspan=""1""][rowspan=""1""]:nth-child(7):nth-last-child(2), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(6) + TD:not([colspan]):not([rowspan]):nth-child(4):nth-last-child(5) + TD:not([colspan]):not([rowspan]):nth-child(5):nth-last-child(4) + TD:not([colspan]):not([rowspan]):nth-child(6):nth-last-child(3) + TD:not([colspan]):not([rowspan]):nth-child(7):nth-last-child(2), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column8", "TABLE[id='DataTables_Table_0'] > * > TR > TH[colspan=""1""][rowspan=""1""]:nth-child(1):nth-last-child(8) + TH[colspan=""1""][rowspan=""1""]:nth-child(2):nth-last-child(7) + TH[colspan=""1""][rowspan=""1""]:nth-child(3):nth-last-child(6) + TH[colspan=""1""][rowspan=""1""]:nth-child(4):nth-last-child(5) + TH[colspan=""1""][rowspan=""1""]:nth-child(5):nth-last-child(4) + TH[colspan=""1""][rowspan=""1""]:nth-child(6):nth-last-child(3) + TH[colspan=""1""][rowspan=""1""]:nth-child(7):nth-last-child(2) + TH[colspan=""1""][rowspan=""1""]:nth-child(8):nth-last-child(1), TABLE[id='DataTables_Table_0'] > * > TR > TD:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(8) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(7) + TD:not([colspan]):not([rowspan]):nth-child(3):nth-last-child(6) + TD:not([colspan]):not([rowspan]):nth-child(4):nth-last-child(5) + TD:not([colspan]):not([rowspan]):nth-child(5):nth-last-child(4) + TD:not([colspan]):not([rowspan]):nth-child(6):nth-last-child(3) + TD:not([colspan]):not([rowspan]):nth-child(7):nth-last-child(2) + TD:not([colspan]):not([rowspan]):nth-child(8):nth-last-child(1), TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column9", "TABLE[id='DataTables_Table_0'] > * > TR > TD[colspan=""9""]:not([rowspan]):nth-child(1):nth-last-child(1)"}}, [RowSelector="TABLE[id='DataTables_Table_0'] > * > TR"]), #"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]) in #"Promoted Headers"
- MekistHelper III
Hello
Although the data is 600 lines, it takes more than 1 hour to load it to the page, can we get extra data, is it possible to shorten the code
- lbendlinSuper User
I only see 46 rows for AKSA. Are you saying you need to do this for 600 different codes?
- MekistHelper III
I'm adding and performing a function at the top of the query as follows, I'm querying multiple company data
(Hisse as text) as table => let Source = Web.BrowserContents("https://www.isyatirim.com.tr/tr-tr/analiz/hisse/Sayfalar/sirket-karti.aspx?hisse=" & Hisse),