Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I am new to Power Bi. I want the user to provide user 2 text inputs (keyword1, keyword2). Basis both, I would want to fetch google news and show the latest news.
Below is the code I got from one of the posts
Function :
(symbol)=>
let
Source = Web.BrowserContents("https://news.google.com/search?q="&symbol&"&hl=en-NZ&gl=NZ&ceid=NZ%3Aen"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", ".nID9nc .DY5T1d"}, {"Column2", ".nID9nc .xBbh9"}, {"Column3", ".nID9nc .wEwyrc"}, {"Column4", ".nID9nc .WW6dff"}, {"Column5", ".nID9nc .hEsB5d"}, {"Column6", ".nID9nc .gQtGhf"}, {"Column7", ".nID9nc .OGsJDe .DPvwYc"}, {"Column8", ".nID9nc .uG2FLd .DPvwYc"}, {"Column9", ".nID9nc .GB1Zid .DPvwYc"}, {"Column10", ".AZtY5d SPAN"}}, [RowSelector=".nID9nc"]),
#"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type text}, {"Column10", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Headline"}, {"Column2", "Detail"}, {"Column3", "Source"}, {"Column4", "Time"}}),
#"Removed Other Columns" = Table.SelectColumns(#"Renamed Columns",{"Headline", "Detail", "Source", "Time"})
in
#"Removed Other Columns"
Below is the file extraction:
let
Source = Excel.Workbook(File.Contents("C:\Users\xxx\Downloads\Search File.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Symbol", type text}}),
#"Invoked Custom Function" = Table.AddColumn(#"Changed Type1", "News_google", each News([Symbol])),
#"Expanded News_google" = Table.ExpandTableColumn(#"Invoked Custom Function", "News_google", {"Headline", "Detail", "Source", "Time"}, {"Headline", "Detail", "Source", "Time"})
in
#"Expanded News_google"
Regarding,
Hema
Solved! Go to Solution.
HI @HDave,
I think you need to get data from the google news API instead of the news pages. The news pages show the result formatted by scripts that get data from source data API.(power bi web connector will block these external scripts and codes from the web page)
Regards,
Xiaoxin Sheng
HI @HDave,
I think you need to get data from the google news API instead of the news pages. The news pages show the result formatted by scripts that get data from source data API.(power bi web connector will block these external scripts and codes from the web page)
Regards,
Xiaoxin Sheng
User | Count |
---|---|
98 | |
90 | |
77 | |
71 | |
64 |
User | Count |
---|---|
114 | |
97 | |
95 | |
68 | |
65 |