Skip to main content

Login and Scrape Protected Content

Log into a website and scrape content behind authentication

Steps

#ActivityWhat it does
1StartWebBrowserOpen the login page
2TextInputEnter username
3TextInputEnter password
4ClickElementClick login button
5WaitForElementWait for dashboard to load
6GetHtmlElementsScrape protected content
7CreateTableCreate an in-memory table for the scraped rows
8ForEachLoopIterate scraped rows and push each into the table
9TableUpsertRowAppend each scraped row to the table
10TableExportExport the rows to Excel

Workflow

StartWebBrowser("https://example.com/login", "useCurrentBrowserSession")
TextInput("//input[@name='username']", text="myuser")
TextInput("//input[@name='password']", text="mypassword")
ClickElement("//button[@type='submit']")
WaitForElement("//div[@class='dashboard']", state="visible")
scrapedData = GetHtmlElements("//table[@class='data']//tr")
CreateTable("protected", schema={"columns": [{"name": "col1"}, {"name": "col2"}]})
for row in scrapedData:
TableUpsertRow("protected", {"col1": "{{ row.col1 }}", "col2": "{{ row.col2 }}"}, append=True)
TableExport("protected", "./scraped_data.xlsx", format="xlsx", sheetName="Data")