Problem with detecting li's and looping over each page

A website has the following format. I am using SourceSearch to count number of li but it comes up as 3. I also need this code to loop after clicking the next page button and when no more next page button it runs this code then code ends