import urllibimport redef getHtml(url): page=urllib.urlopen(url) html=page.read() return htmlhtml= getHtml("http://tieba.baidu.com/p/24601508...
分类:
编程语言 时间:
2014-08-11 20:32:22
阅读次数:
197
#_*_coding:utf-8-*-import urllib2import tracebackimport codecsfrom BeautifulSoup import BeautifulSoupdef openSoup(url,code): page = urllib2.urlopen...
分类:
其他好文 时间:
2014-08-09 13:19:37
阅读次数:
283
#_*_coding:utf-8-*-import urllib2import tracebackimport codecsfrom BeautifulSoup import BeautifulSoupdef openSoup(url,code): page = urllib2.urlopen...
分类:
Web程序 时间:
2014-08-08 21:14:36
阅读次数:
311
正则表达式与python的网页操作练习一:importurllib.request
importre
qname=input(‘inputenglish:‘)
qname=qname.strip()
url=‘http://dict.youdao.com/search?le=eng&q=‘+qname+‘&keyfrom=dict.top‘
html=urllib.request.urlopen(url)
source=html.read().decode(‘U..
分类:
编程语言 时间:
2014-07-31 17:21:47
阅读次数:
242
以前的python2.x的时候:
try:
fp=urllib.request.urlopen(blogurl)
except Exception, e:
print (e)
print('download exception %s' % blogurl)
return 0
现在python3.x的时候:
...
分类:
编程语言 时间:
2014-07-29 14:58:28
阅读次数:
279
urllib2.urlopen(url[, data][, timeout])Open the URL url, which can be either a string or a Request object.data may be a string specifying additional d...
分类:
编程语言 时间:
2014-07-22 23:08:32
阅读次数:
219
由于python目前不能直接处理中文路径,必须要转化一下,如下例子是下载图片(名字为中文的): def getInfo(self,imageurl): response = urllib.request.urlopen(imageurl).read().decode('utf-8')# with o...
分类:
编程语言 时间:
2014-07-21 08:09:58
阅读次数:
210
1. urlopen可以给一个Request Object返回一个response object,read()读取相应对象的内容,这时候的print(the_page)可以输出网页的html内容1 import urllib22 3 req = urllib2.Request('http://www...
分类:
编程语言 时间:
2014-07-20 09:03:38
阅读次数:
301
一 不需要登录的import urllib2content = urllib2.urlopen('http://XXXX').read() 二 使用代理import urllib2proxy_support = urllib2.ProxyHandler({'http':'http://XX.XX.....
分类:
编程语言 时间:
2014-07-16 17:58:39
阅读次数:
226
import urllib2response=urllib2.urlopen('http://house.focus.cn/')html=response.read()print html.decode('gbk')
分类:
编程语言 时间:
2014-06-27 00:50:29
阅读次数:
333