python实现网络爬虫学习总结
来源:互联网 发布:mysql 两个字段排序 编辑:程序博客网 时间:2024/06/05 19:22
import urllib2import urllibdef openUrl(strUrl): response = urllib2.urlopen(strUrl) retContent = response.read() return retContent def writeFile(content, outputPath, mode='w'): strInput = '' if type(content) != type(""): return False else: f = open(outputPath, mode) f.write(content) f.close return True'''retUrl = openUrl('')writeFile(retUrl, 'login.html', 'w')'''user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'headers = { 'User-Agent' : user_agent }url = ''data = {}data['uid'] = ''data['password'] = '#data['verifyCode'] = '2345'data = urllib.urlencode(data)req = urllib2.Request(url, data)try: response = urllib2.urlopen(req)except urllib2.URLError, e: print e.code print '==============' response = "request error"if type(response) != type(''): the_page = response.read()else: the_page = 'error'writeFile(the_page, 'postLogin.html')
自己写的实例
0 0
- python实现网络爬虫学习总结
- [Python]网络爬虫总结
- Python实现网络爬虫
- Python实现网络爬虫
- Python实现网络爬虫
- python实现网络爬虫
- python实现网络爬虫
- [Python] 实现网络爬虫
- python实现网络爬虫
- Python实现网络爬虫
- [Python] 实现网络爬虫
- Python实现网络爬虫
- Python 实现网络爬虫
- Python实现网络爬虫
- python实现网络爬虫
- python网络爬虫学习
- Python网络爬虫学习
- 网络爬虫学习 python
- 用逗号来格式化数字
- WinForm使用的缓存类
- div.onblur的两个解决方法、跳出详细框的控制
- android开发给eclipse安装ADT插件遇到NDK pluign无法安装的错误
- 技术篇--shell中只列出目录的方法
- python实现网络爬虫学习总结
- 感想
- 页面自动执行(加载)js的几种方法
- 移动端小技巧
- SQL高效先进先出算法
- 图形编程——Paint和Canvas的基本使用
- set 的使用方法
- 马云太恐怖了
- 马云太恐怖了