码迷,mamicode.com
首页 >  
搜索关键字:urlopen    ( 699个结果
一个简单的爬虫脚本--宅男福利
闲来无事,扒一扒那些美女们的照片importurllib.request url="http://img1.mm131.com/pic/2537/" foriinrange(1,50,1): page_url=url+str(i)+‘.jpg‘ response=urllib.request.urlopen(page_url) cat_img=response.read() filename=page_url.split(‘/‘)[-1] withopen(filename,‘..
分类:其他好文   时间:2016-07-01 23:10:07    阅读次数:229
python BeautifulSoup获取 网页链接的文字内容
这里和获取链接略有不同,不是得到链接到url,而是获取每个链接的文字内容#!/opt/yrd_soft/bin/python importre importurllib2 importrequests importlxml frombs4importBeautifulSoup url=‘http://www.baidu.com‘ #page=urllib2.urlopen(url) page=requests.get(url).text ..
分类:编程语言   时间:2016-06-27 00:09:57    阅读次数:240
python 爬虫的一些使用技巧
1.最基本的抓站 import urllib2 content = urllib2.urlopen('http://XXXX').read() import urllib2 content = urllib2.urlopen('http://XXXX').read() -2.使用代理服务器这在某些情 ...
分类:编程语言   时间:2016-06-23 18:35:14    阅读次数:166
Python中urlopen()介绍
#以下介绍是基于Python3.4.3 一. 简介 urllib.request.urlopen()函数用于实现对目标url的访问。 函数原型如下:urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=Non ...
分类:编程语言   时间:2016-06-22 21:59:20    阅读次数:328
网络爬虫(2)--异常处理
上一节中对网络爬虫的学习的准备工作作了简要的介绍,并以一个简单的网页爬取为例子。但网络是十分复杂的,对网站的访问并不一定都会成功,因此需要对爬取过程中的异常情况进行处理,否则爬虫在遇到异常情况时就会发生错误停止运行。 让我们看看urlopen中可能出现的异常: html = urlopen("htt ...
分类:其他好文   时间:2016-06-22 20:19:57    阅读次数:146
urllib2
【urllib2】 1、urllib2.urlopen(),参数可填url字符串,或者一个Request对象。 2、Request对象的set_proxy(proxy, type)可以设置代理。 3、urlopen的返回值的read()方法,可以body内容读取出来。 参考:https://docs ...
分类:Web程序   时间:2016-06-17 17:21:22    阅读次数:156
Python2 抓取百度贴吧图片
我这里抓取的百度贴吧的地址是http://tieba.baidu.com/p/2460150866?pn=1。以下是源码,使用的是python2。importre importurllib #抓取页面的源码 defgetHtml(url): page=urllib.urlopen(url) html=page.read() returnhtml #下载源码中指定的图片 defgetImg(html): reg=r‘src..
分类:编程语言   时间:2016-06-13 19:30:50    阅读次数:249
"urllib"库的学习
在习题—41遇到这个模块/库, 有兴趣的参考下面这个网址: http://blog.sina.com.cn/s/blog_b369b20d0101kb7m.html # coding: utf-8 import urllib # 导入urllib模块 baidu = urllib.urlopen(' ...
分类:Web程序   时间:2016-06-11 02:00:01    阅读次数:178
python简单爬虫示例
#coding=utf-8 import urllib import re def downloadPage(url): h = urllib.urlopen(url) return h.read() def downloadImg(content): pattern = r'src="(.+?\. ...
分类:编程语言   时间:2016-05-25 00:31:36    阅读次数:254
Python3学习笔记(urllib模块的使用)转http://www.cnblogs.com/Lands-ljk/p/5447127.html
Python3学习笔记(urllib模块的使用) 1.基本方法 urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None) - url: 需 ...
分类:编程语言   时间:2016-05-19 18:59:19    阅读次数:201
699条   上一页 1 ... 49 50 51 52 53 ... 70 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!