码迷,mamicode.com
首页 >  
搜索关键字:urlopen    ( 699个结果
urllib源码简单分析
对下面这段代码做分析import urllibparams = urllib.urlencode({'wd': 'python'})f = urllib.urlopen("http://www.baidu.com/s?%s" % params)print f.read()这是一段简单读取url内容的...
分类:Web程序   时间:2015-09-20 01:45:30    阅读次数:349
any
from urllib2 import Request, urlopen, URLError, HTTPError req = Request('http://bbs.csdn.net/callmewhy') try: response = urlopen(req) except...
分类:其他好文   时间:2015-09-16 19:49:50    阅读次数:182
Python网络爬虫 - 2. Beautiful Soup小试牛刀
目标:我们解析百度首页的logobs_baidu_logo.pyfrom urllib.request import urlopenfrom bs4 import BeautifulSouphtml = urlopen("http://www.baidu.com")bsObj = Beautiful...
分类:编程语言   时间:2015-09-16 12:48:22    阅读次数:220
python 获取网页图片 保存在本地
import?urllib import?string import?re def?getHtml(url): page=urllib.urlopen(url) html=page.read() return?html def?getPic(html): imgre=re.compile(r‘src=".+?\.jpg"?data-big-img‘) imglist...
分类:编程语言   时间:2015-09-09 17:45:55    阅读次数:200
简单 python爬虫 <2>
#!/usr/bin/envpython #coding=utf-8 ‘‘‘ @这个脚本会将指定网页中的壁纸图片下载到本地 ‘‘‘ importurllib importre defget_html_info(url): ‘‘‘@获取网页源代码‘‘‘ html=urllib.urlopen(url) html_info=html.read() returnhtml_info defget_img(info): ‘‘‘@获取通过正则表..
分类:编程语言   时间:2015-09-08 15:36:21    阅读次数:229
python的urllib2包基本使用方法
1.urllib2.urlopen(request)url="http://www.baidu.com" #url还可以是其他协议的路径,比如ftp values={‘name‘:‘MichaelFoord‘,‘location‘:‘Northampton‘,language‘:‘Python‘} data=urllib.urlencode(values) user_agent=‘Mozilla/4.0(compatible;MSIE5.5;WindowsNT)‘ header..
分类:编程语言   时间:2015-09-08 07:12:01    阅读次数:259
[踩坑]python实现并行爬虫
问题背景:指定爬虫depth、线程数, python实现并行爬虫   思路:    单线程 实现爬虫类Fetcher                 多线程 threading.Thread去调Fetcher  方法:Fetcher 中,用urllib.urlopen打开指定url,读取信息:response = urllib.urlopen(self.url) content = respon...
分类:编程语言   时间:2015-09-07 22:55:23    阅读次数:248
在python3中使用urllib.request编写简单的网络爬虫
Python官方提供了用于编写网络爬虫的包 urllib.request, 我们主要用它进行打开url,读取url里面的内容,下载里面的图片。分以下几步:step1:用urllib.request.urlopen打开目标网站step2:由于urllib.request.urlopen返回的是一个ht...
分类:编程语言   时间:2015-09-03 23:18:09    阅读次数:466
urllib.error.HTTPError: HTTP Error 403: Forbidden
问题:urllib.request.urlopen() 方法经常会被用来打开一个网页的源代码,然后会去分析这个页面源代码,但是对于有的网站使用这种方法时会抛出"HTTP Error 403: Forbidden"异常例如 执行下面的语句时[python] urllib.request.urlopen...
分类:Web程序   时间:2015-08-31 18:54:28    阅读次数:169
Python 3.4 - urllib.request 学习爬虫爬网页(一)
比如爬baidu.com,  在python 3.4 中应该这么写 import urllib.request def getHtml(url): page = urllib.request.urlopen(url) html = page.read() return html html = getHtml("http://baidu.com") print (html...
分类:编程语言   时间:2015-08-27 15:14:06    阅读次数:141
699条   上一页 1 ... 55 56 57 58 59 ... 70 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!