fairypp / Python_Learning

14 stars 8 forks source link

_This is what my code looked like - #23

Open saimouli29 opened 4 years ago

saimouli29 commented 4 years ago

This is what my code looked like - it is set to ignore the SSL Certifications which could have created errors. import urllib.request from bs4 import BeautifulSoup

url = 'http://py4e-data.dr-chuck.net/known_by_Nia.html' count = int(input('Enter count:')) position = int(input('Enter position:')) postion=int(position)-1 html = urllib.request.urlopen(url) html = html.read()

soup = BeautifulSoup(html,"html.parser") href = soup('a')

print ("Retrieving:",href)

for i in range(count): print ("Retrieving:",href[i]) link = href[position].get('href', None) result = (href[position].contents[0]) html = urllib.request.urlopen(url) html = html.read() soup = BeautifulSoup(html,"html.parser") href = soup('a') print(result)