import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = input('Enter URL: ')
count = int(input('Enter count: '))
position = int(input('Enter position: '))
for i in range(count):
print("Retrieving:",url)
html = urllib.request.urlopen(url, context=ctx).read()
soup = BeautifulSoup(html, 'html.parser')
tags = soup('a')
name = tags[position-1].text.strip()
link = tags[position-1].get('href', None)
url=link
print("Retrieving:",url)
print("Name:",name)