response = urllib.request.urlopen('http://www.iqiyi.com/a_19rrgja8xd.html')
html = response.read()
soup = BeautifulSoup(html)
dramaList =Soup.findAll('div', attrs={'class':'list_block1 align_c'})
dramaItems = []
if(dramaList):
lis = DramaList[0].findAll('li')
for li in lis:
ps = li.findAll('p')
description = ps[1].text if len(ps)>1 else ''
num = ps[0].find('a').text
url = ps[0].find('a' )['href']
di = DramaItem(num, description, url)
DramaItems.append(di)
dramaItems の di の場合:
print(di)
diLen = len(dramaItems)
userChoice = int(input('ドラマを視聴する番号を入力してください:'))
if userChoice > ;= 1 および userChoice <=diLen:
DramaItems[userChoice-1].openDrama()