python抓取网页的代码
2016-05-10 17:14
387 查看
import urllib import urllib2 url = 'http://www.uuorange.com' user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' values = {'name' : 'Michael Foord', 'location' : 'pythontab', 'language' : 'Python' } headers = { 'User-Agent' : user_agent } data = urllib.urlencode(values) req = urllib2.Request(url, data, headers) response = urllib2.urlopen(req) the_page = response.read() print the_page
相关文章推荐
- Python实现ping指定IP
- [LeetCode]题解(python):155-Min Stack
- Python下使用OpenCV的配置
- [python]使用xlrd对Excel表格进行读写操作
- [LeetCode]题解(python):154-Find Minimum in Rotated Sorted Array II
- [LeetCode]题解(python):153-Find Minimum in Rotated Sorted Array
- Python urlib vs urlib2
- Python multiprocessing
- python ajax爬虫 --36Kr为例
- python面向对象编程III(定制类)
- [LeetCode]题解(python):152-Maximum Product Subarray
- Python Socket
- python的import几种形式
- [LeetCode]题解(python):151-Reverse Words in a String
- Python 基础学习笔记1
- Python树结构之一行代码实现
- Python全局变量
- [python网络编程]使用scapy修改源IP发送请求
- python automated headers 自动生成格式化 注释文件 docstrings
- thrift系列 - 多语言实例 for java和python