requests + tkinter 获取网页数据

代码:

from tkinter import *
import requests


window = Tk()
window.geometry('500x350+500+100')
window.title('数据采集')

frame = Frame(window)
frame.pack()

Label(frame,text='请输入网站地址:').pack()
address = Entry(frame,width=50)
address.pack()

Label(frame,text='结果将在下方展示:').pack()
txt = Text(frame,height=10)
txt.pack()

def submit():
    global txt
    addr = address.get()
    res = requests.get(addr).text
    txt.insert(INSERT,res)

Button(frame,text='提交',command=submit).pack()

window.mainloop()

  

效果:

requests + tkinter 获取网页数据

 

上一篇:C++指针知识回顾(预备)


下一篇:1. 爬虫请求模块