码迷,mamicode.com
首页 >  
搜索关键字:urlopen    ( 699个结果
Python抓取网页内容
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
抓取天涯文章的蜘蛛代码,刚经过更新(因为天涯页面HTML代码变化)
#_*_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】简单的网页内容获取 - 有道翻译英文
正则表达式与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
python3.x的异常处理
以前的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
【python】urllib2
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
python3 网址路径中带中文的处理办法
由于python目前不能直接处理中文路径,必须要转化一下,如下例子是下载图片(名字为中文的): def getInfo(self,imageurl): response = urllib.request.urlopen(imageurl).read().decode('utf-8')# with o...
分类:编程语言   时间:2014-07-21 08:09:58    阅读次数:210
Some in urllib2 - python2.7
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
python抓取网页
一 不需要登录的import urllib2content = urllib2.urlopen('http://XXXX').read() 二 使用代理import urllib2proxy_support = urllib2.ProxyHandler({'http':'http://XX.XX.....
分类:编程语言   时间:2014-07-16 17:58:39    阅读次数:226
Python抓取页面乱码问题的解决
import urllib2response=urllib2.urlopen('http://house.focus.cn/')html=response.read()print html.decode('gbk')
分类:编程语言   时间:2014-06-27 00:50:29    阅读次数:333
699条   上一页 1 ... 67 68 69 70 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!