Python tkinter和web抓取和调用功能

时间:2018-04-04 02:14:58

标签: python function tkinter

我是python编程的新手,并且正在开发一个新的tkinter应用程序。我被困在一个特定的地方。以下是我的代码

我想要完成的是当我点击带有command = getval的按钮时。 Tt将根据请求扫描页面。我面临的问题是,我的代码变得越来越大,我想使用函数并在我的主程序中调用它们,但我被卡住了。关于如何为上述代码调用函数的任何建议。

提前致谢。

def getval():
    if len(Ent1.get()) == 0:
        print("Enter a ticker value in the block")
    else:
        ticker = str(Ent1.get())
        request = requests.get(("http://money.cnn.com/quot/quote.html?symb=") + (ticker))
        content = request.content
        soup = BeautifulSoup(content, "html.parser")

0 个答案:

没有答案