import urllib
response = urllib.request.urlopen('http://math.sysu.edu.cn/main/default/index.aspx')
html = response.read()
html = html.decode('utf-8')
print(html)上述代码会出现如下错误:UnicodeDecodeError: 'utf-8'...
分类:
编程语言 时间:
2015-07-23 17:56:35
阅读次数:
206
http://www.dianping.com/shop/8010173 File "综合商场1.py", line 152, in httpCrawler(url) File "综合商场1.py", line 34, in httpCrawler getEachShop(shops) File ....
分类:
Web程序 时间:
2015-07-21 11:57:45
阅读次数:
1039
一、urllib2发送请求import urllib2
url = 'http://www.baidu.com'
req = urllib2.Request(url)
response = urllib2.urlopen(req)
print response.read()
print response.geturl()
print response.info()
urllib2用一个Re...
分类:
Web程序 时间:
2015-07-16 22:16:01
阅读次数:
121
importurllibdefmain():url='http://www.qq.com'url1=urllib.urlopen(url)#printurl1.read()打印源代码#printurl1.info()头信息#printurl1.getcode()状态码#printurl1.getur...
分类:
编程语言 时间:
2015-07-16 18:52:56
阅读次数:
123
因为工作的关系,我写过许多个抓取网站信息的程序。 最简单的,只要用Python的urllib2.urlopen()函数就可以了; 然后,有个网站喜欢封人,所以,得找一批代理,轮流抓它的信息; 有的网站不允许程序抓取,所以,就...
分类:
编程语言 时间:
2015-07-12 23:32:04
阅读次数:
390
import urllib2
import json
def get_all_switches():
url = "http://127.0.0.1:8080/v1.0/topology/switches"
req = urllib2.Request(url)
res_data = urllib2.urlopen(req)
res = res_data.read(...
urllib.request.urlopen(url).read().decode('utf-8')url中带中文参数会出错:UnicodeEncodeError: 'ascii' codec can't encode characters in position 84-86: ordinal no...
分类:
编程语言 时间:
2015-06-27 22:39:29
阅读次数:
197
#!/usr/bin/env python2#-*- coding: utf-8 -*-import urlliburl = "http://www.baidu.com"def getHtml(url): page = urllib.urlopen(url) html = page.re...
分类:
编程语言 时间:
2015-06-25 15:23:57
阅读次数:
122
python爬爬爬之单网页html页面爬取
作者:vpoet
日期:大约在夏季
注:随意copy 不用告诉我
#coding:utf-8
import urllib2
Response=urllib2.urlopen("http://www.baidu.com");
Html=Response.read();
print Html;
运行结果:
...
分类:
编程语言 时间:
2015-06-23 21:41:36
阅读次数:
173
目标:下载贴吧或空间中所有图片步骤:(1)获取页面代码 (2)获取图片URL,下载图片代码如下:#!/usr/bin/pythonimport reimport urllibdef getHtml(url): page=urllib.urlopen(url) html=page.read...
分类:
编程语言 时间:
2015-06-22 22:07:00
阅读次数:
208