How to scrap data from web on multiple levels of pages


Hello everyone i want to perform web scrapping ,i want to scrap top level pages(mostly consisting of page titles) and then scrap data inside every single page by clicking on page titles ,but the problem is how to record that sequence of going inside one page then coming back to the top page and then making that sequence automatic for other pages ??
Does anyone know ??