📘 Example Scripts
This page showcases common automation tasks written in Fuyu's scripting language. Use these as references or inspiration when writing your own.
🔐 Login and Persist Session
visit("https://example.com/login")
load_cookies()
refresh()
if not find_element(".logged-in")
find_element("#email").input(account.email)
find_element("#password").input(account.password)
find_element("button[type='submit']").click()
wait(3)
save_cookies()
end
record("status", "logged in")
🛍 Scrape Product Titles and Prices
visit("https://example.com/products")
wait_for(".product", 5)
products = find_elements(".product")
for p in products
name = p.find_element(".title").text
price = p.find_element(".price").text
record("name", name)
record("price", price)
end
🌐 Visit URLs from a Dataset
rows = read("urls")
for row in rows
visit(row.url)
wait(2)
title = get_title()
record("url", row.url)
record("title", title)
end
✍️ Submit a Form with Datasets
rows = read("form-data")
for row in rows
visit("https://example.com/form")
find_element("input[name='name']").input(row.name)
find_element("input[name='email']").input(row.email)
find_element("textarea[name='message']").input(row.message)
find_element("button[type='submit']").click()
wait(2)
record("submitted", row.email)
end
🧩 Solve Text-Based Captcha
visit("https://example.com/signup")
find_element("input[name='email']").input("[email protected]")
captcha_el = find_element(".captcha")
if captcha_el
token = resolve_captcha(captcha_el)
find_element("input[name='captcha']").input(token)
end
find_element("button[type='submit']").click()
record("status", "captcha submitted")
🎰 Randomize Behavior
delay = random(2, 6)
print("Waiting for", delay, "seconds")
wait(delay)
record("delay", delay)