このpythonコードを使って出力を得る方法を理解できません。美味しいスープを使ってHTMLリンクリストを7回循環させた後の18番目の姓を見つけよう
HTML file < ----ここ
import urllib
from BeautifulSoup import *
url = raw_input('Enter URL - ')
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)<----Here we are reading the .html file word by word
Count_ = raw_input('Enter Count - ') <----------
Position_ = raw_input('Enter Position - ')<-----We are asking user to input the values of "Count", and "Position" variables.
# Retrieve all of the anchor tags
tags = soup('a') <----Extracting all anchor tags using the Beautiful Soup program.
final = ""
curpos = ""
をクリックして私は、このコードの目的であっても、ロジックを理解していません。
count= int(Count_) + 1
while count > 0 :
pos = 0
for tag in tags:
if pos == int(Position_) - 1:
curpos = tag.get('href', None)
break
pos = pos + 1
final = curpos
url = str(curpos)
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)
tags = soup('a')
count = count - 1
print final
誰か助けてもらえますか?