diff --git a/Access Web Data/following_link.py b/Access Web Data/following_link.py new file mode 100644 index 0000000..f5e4793 --- /dev/null +++ b/Access Web Data/following_link.py @@ -0,0 +1,14 @@ +import urllib.error, urllib.request, urllib.parse +from bs4 import BeautifulSoup +a = int(input("Position: "))-1 +b = int(input("Times: ")) +url = input("Enter URL: ") + +for c in range(b): + html= urllib.request.urlopen(url).read() + soup = BeautifulSoup(html,'html.parser') + tags = soup('a') + d = tags[a].get('href',None) + url=d + e = tags[a].contents[0] +print(e)