퀴즈
1. 스플릿 하기
2.url 만들기
3.url 검사
단!!! com 만되게 해놧다
co.kr은 안됨!~!!
나중에 정규식 고쳐야한다~!
import requests
from bs4 import BeautifulSoup
def finding(biglist):
country = input("#: ")
if country.isdecimal():
number = int(country)
if number <= len(biglist):
print("You chose", biglist[number][1])
print("The currency code is", biglist[number][3].upper())
else:
print("Choose a number from the list.")
return finding()
else:
print("That wasn\'t a number.")
return finding()
def findurlcode():
indeed_result = requests.get('https://www.iban.com/currency-codes')
indeed_soup = BeautifulSoup(indeed_result.text, "html.parser")
datalist = indeed_soup.find(
"table", {"class": "table table-bordered downloads tablesorter"})
pages = datalist.find_all('tr')
biglist = []
count = 0
for i in pages[1:]:
minilist = []
minilist.append(count)
for k in i:
if k != "\n":
data = str(k.string)
if data.isdecimal():
minilist.append(int(data))
else:
minilist.append(data[0] + data[1:].lower())
if type(minilist[4]) == type(0):
biglist.append(minilist)
count += 1
return biglist
def firstwork():
biglist = findurlcode()
for i in biglist:
print("#", i[0], i[1])
return biglist
def startgame():
print("Hello! Please choose select a country by number:")
biglist = firstwork()
finding(biglist)
'nomadcoders 공부 심화' 카테고리의 다른 글
2주 첼린지~ 6일차 (nomadcoders) (0) | 2020.08.30 |
---|---|
2주 첼린지~ 5일차 (nomadcoders) (0) | 2020.08.30 |
2주 첼린지~ 3일차 (nomadcoders) (1) | 2020.08.28 |
2주 첼린지~ 2일차 (nomadcoders) (0) | 2020.08.28 |
2주 첼린지~ 1일차 (nomadcoders) (0) | 2020.08.28 |