Intro
Learning Objectives
- First
Description
- First
Hints
- First
Video Guide
Additional Material
Project code
Copy and paste this into an empty Power Automate Desktop flow.
# Gets the the date and converts it to the format of the web page
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyy-MM-dd''' Result=> FormattedDateTime
# Creates a Result DataTable to write the results to
SET Result TO { ^['Title', 'Category', 'Sub Category', 'URL'] }
WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://star.dk/soeg/?q=*&sort-desc=ManualDate&maxResults=1000&ManualDateFrom=2022-01-01&ManualDateTo=%FormattedDateTime%''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 BrowserInstance=> Browser
WebAutomation.ExtractData.ExtractTable BrowserInstance: Browser Control: $'''html > body > main > div > div > div > div > div > div > article > div:eq(1) > ul:eq(0) > li''' ExtractionParameters: {[$'''a > span:eq(0)''', $'''Own Text''', $'''''', $'''Value #1'''], [$'''a > h2''', $'''Own Text''', $'''''', $'''Value #2'''], [$'''a''', $'''Href''', $'''''', $'''Value #3'''] } PostProcessData: False TimeoutInSeconds: 60 ExtractedData=> DataFromWebPage
WebAutomation.CloseWebBrowser BrowserInstance: Browser
LOOP FOREACH CurrentItem IN DataFromWebPage
# Uses RegEx to parse the category/sub category into seperate items
Text.ParseText.RegexParseForFirstOccurrence Text: CurrentItem[0] TextToFind: $'''^[^\\/]*(?= \\/ )''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position Match=> Category
Text.ParseText.RegexParseForFirstOccurrence Text: CurrentItem[0] TextToFind: $'''(?<= \\/ ).*(?= \\/ )''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position2 Match=> SubCategory
# Adds a line with data to the result datatable
SET Result TO Result + [CurrentItem[1], Category, SubCategory, CurrentItem[2]]
END
# Writes back into Excel
Excel.LaunchExcel.LaunchUnderExistingProcess Visible: False Instance=> ExcelInstance
Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: {['Title', 'Category', 'Sub Category', 'URL'] } Column: $'''A''' Row: 1
Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: Result Column: $'''A''' Row: 2
Folder.GetSpecialFolder SpecialFolder: Folder.SpecialFolder.DesktopDirectory SpecialFolderPath=> SpecialFolderPath
Excel.CloseExcel.CloseAndSaveAs Instance: ExcelInstance DocumentFormat: Excel.ExcelFormat.FromExtension DocumentPath: $'''%SpecialFolderPath%\\Results.xlsx'''