【脚本语言系列】关于PythonWeb访问urllib,你需要知道的事
2017-05-10 13:31
651 查看
如何使用urllib
# -*- coding:utf-8 -*- # import Tkinter import urllib class Window: def __init__(self, root): self.root = root self.entryUrl = Tkinter.Entry(root) self.entryUrl.place(x = 5, y = 15) self.get = Tkinter.Button(root, text = '下载页面', command = self.Get) self.get.place(x = 120, y = 15) self.edit = Tkinter.Text(root) self.edit.place(y = 50) def Get(self): url = self.entryUrl.get() page = urllib.urlopen(url) data = page.read() self.edit.insert(Tkinter.END, data) page.close() root = Tkinter.Tk() window = Window(root) root.minsize(600, 480) root.mainloop()
试一下访问[示例网址](http://www.163.com)
什么是urllib
使用Python的urllib模块可以创建一个简单的访问网站的脚本,获取指定的页面。如果使用GUI库中显示HTML的组件,还可以制作一个简单的Python Web浏览器。
使用urllib进行简单地访问、下载页面内容。
相关文章推荐
- 【脚本语言系列】关于PythonWeb客户端-服务器模块http-urllib,你需要知道的事情
- 【脚本语言系列】关于PythonWeb访问ftplib,你需要知道的事
- 【脚本语言系列】关于Python游戏工具Pygame,你需要知道的事
- 【脚本语言系列】关于Python调试报错,你需要知道的事
- 【脚本语言系列】关于Python邮件服务poplib,你需要知道的事
- 【脚本语言系列】关于Python测试工具Pyflakes, 你需要知道的事
- 【脚本语言系列】关于Python机器学习scikits-learn,你需要知道的事
- 【脚本语言系列】关于Python测试工具lettuce, 你需要知道的事
- 【脚本语言系列】关于Python图像处理PIL,你需要知道的事
- 【脚本语言系列】关于Python统计分析statsmodel,你需要知道的事
- 【脚本语言系列】关于Python邮件服务smtplib,你需要知道的事
- 【脚本语言系列】关于Python数值计算Pandas,你需要知道的事
- 【脚本语言系列】关于Python开发环境搭建,你需要知道的事
- 【脚本语言系列】关于Python数据库处理SQLite,你需要知道的事
- 【脚本语言系列】关于Python数据库处理MySQL, 你需要知道的事
- 【脚本语言系列】关于PythonGUI界面PythonWin,你需要知道的事
- 【脚本语言系列】关于Python测试工具unittest, 你需要知道的事
- 【脚本语言系列】关于Python测试工具mock, 你需要知道的事
- 【脚本语言系列】关于Python性能分析工具timeit, 你需要知道的事
- 【脚本语言系列】关于Python测试工具docstrings, 你需要知道的事