我正在开发一个搜索音乐程序。 但是我有一个问题,打印不是我的意图,所以我需要帮助。 我用tkinter,requests,lxml,BeautifulSoup开发 为什么会发生此错误?
这是我的代码
window = tkinter.Tk()
window.title('TEST')
window.geometry("640x400+100+100")
window.resizable(False, False)
def Search(event):
listBox.delete(0, 'end')
count = 1
query = urlencode(entry.get())
URL = 'https://music.bugs.co.kr/search/lyrics?q=' + query
session = requests.Session()
headers = session.get(URL)
temp = headers.cookies.get_dict()
temp['User-Agent'] =
res = requests.get(URL, headers=temp)
soup = BeautifulSoup(res.text, 'lxml')
title = soup.find_all('p', {'class': 'title'})
artist = soup.find_all('p', {'class': 'artist'})
for song, singer in zip(title, artist):
titles = song.get_text()
artists = singer.get_text()
listBox.insert(count, "title : " + titles.strip())
listBox.insert(count, "artist : " + artists.strip())
count+=1
entry = tkinter.Entry(window)
entry.bind("<Return>", Search)
entry.pack()
listBox = tkinter.Listbox(window, selectmode='extended', height = 0, width=300)
listBox.delete(0)
listBox.pack()
window.mainloop()