Extract page titles to CSV with Apify
Run Apify’s Web Scraper on a few pages, check the titles and URLs in the dataset, and export the results to CSV.
What you will create
Extract the titles of two pages you manage, then verify a CSV containing requested address, loaded address and title. The goal is a small reproducible check, not a general web crawl.
Before you start
Use an already configured Apify account and two public pages you control, accessible without signing in. Check costs and limits before any run. Do not import session cookies or personal data. If a page denies access, stop this test rather than bypassing the restriction.
Step-by-step
- Open the official apify/web-scraper Actor, not Playwright Scraper. Replace all Start URLs examples with your two addresses.
- Clear Link selector. Replace the page function with the code below: it clicks nothing and adds no new URLs to the queue.
- Set Max pages per run to 2 and Max concurrency to 1. The page limit is a safeguard, not a guaranteed billing cap. Also review cost and duration settings before execution.
- Run only if this test is authorized. Inspect run status and errors, then its dataset. Compare addresses and titles with the actual pages.
- In the dataset, choose Export, CSV format, then Download. Open the file importing columns as text and check the resulting rows.
Example to adapt
Minimal code for Web Scraper:
async function pageFunction(context) {
return {
requestedUrl: context.request.url,
loadedUrl: window.location.href,
title: document.title.trim()
};
}Use distinct titles on your test pages, such as “Paper workshop” and “Help: materials”. The expected title is the browser-tab title, not necessarily the large heading visible on the page. Supply your own addresses; do not run the test against a fictional domain.
Check your result
- Are both expected pages represented without unexpected URLs?
- Does a redirect explain any difference between requestedUrl and loadedUrl?
- Does each title match its page’s browser tab?
- Does the CSV contain three separate columns with readable accented characters?
- Is a missing row explained through logs rather than replaced with an invented value?
Common problems
An incomplete dataset may result from an error, redirect or duplicate pages. An inherited function can add URLs even with an empty Link selector: replace it rather than appending this code. If a title appears late after loading, this small example may be insufficient; do not assume universal extraction. Do not schedule repeat runs before understanding the first result.
Next steps
Visit the Apify overview. Keep the CSV and test configuration, without secret keys, before adding another column.



