Skip to content
Advertisement

Looping through HTML & following links

I am writing a code that is supposed to open a url, identify the 3rd link and repeat this process 3 times (each time with the new url).

I wrote a loop (below), but it seems to each time sart over with the original url.

Can someone help me fix my code?

JavaScript

Advertisement

Answer

You need to define the empty list within the loop. The following code works:

JavaScript

Result in terminal:

JavaScript
Advertisement