High school student Python project "T"

Asked 2 years ago, Updated 2 years ago, 93 views

print('From what number to what number do you want to save in Notepad?')
a,b = int(input().split(' '))
with open('{}~{}.txt'.format(a, b), 'w', encoding='UTF-8') as f:
    for i in range(a,b+1):
        lotto_url = "https://dhlottery.co.kr/gameResult.do?method=byWin"
        lotto_get = req.get(lotto_url, params={"method":"byWin","drwNo":"{}".format(i)})
        spoon = bs(lotto_get.content, 'lxml')
        get_win_num = []
        get_bonus_num = 0
        for num in spoon.select('.win span'):
            get_win_num.append(num.text)
        for num in spoon.select('.bonus span'):
            get_bonus_num = num.text
        for number in get_win_num:
            f.write(number)
        f.write(get_bonus_num)
        f.write('\n')

I want to get the lottery number and bonus number as many times as I specified in this notepad, but can you tell me why I made a mistake? ㅠ<

project web-crawling

2022-09-20 08:57

1 Answers

The int(input().split(")) error occurs first. You must replace this with map(int, input().split("").


2022-09-20 08:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.