码迷,mamicode.com
首页 >  
搜索关键字:urllib2    ( 900个结果
一个简单的python爬虫,以豆瓣妹子“http://www.dbmeizi.com/category/2?p= ”为例
本想抓取网易摄影上的图,但发现查看html源代码时找不到图片的url,但firebug却能定位得到。(不知道为什么???)目标是抓取前50页的爆乳图,代码如下:import urllib2,urllib,re,os'''http://www.dbmeizi.com/category/2?p=%'''...
分类:数据库   时间:2014-10-01 21:26:21    阅读次数:312
Web客户端访问
1、获取web页面#coding:utf-8import sys,urllib2req=urllib2.Request(sys.argv[1])fd=urllib2.urlopen(req)while 1: data=fd.read(1024) if not len(data): ...
分类:Web程序   时间:2014-09-30 14:31:59    阅读次数:147
Python网页抓取2
#!coding:utf-8# 获取web页面import sys,urllib2req=urllib2.Request(sys.argv[1])fd=urllib2.urlopen(req)while 1: data=fd.read() if not len(data): ...
分类:编程语言   时间:2014-09-29 16:42:11    阅读次数:165
获取主机信息(python)
#!/usr/bin/envpython fromsubprocessimportPopen,PIPE importurllib,urllib2 importshlex,re defgetIfconfig(): p=Popen([‘ifconfig‘],stdout=PIPE) returnp.stdout.read().split(‘\n\n‘) defparseIfconfig(data): macaddr=data.split(‘\n‘)[0].split()[-1] ipaddr=data.spl..
分类:编程语言   时间:2014-09-27 19:43:20    阅读次数:320
python urllib2 模拟网站登陆
python urllib2 模拟网站登陆1. 可用浏览器先登陆,然后查看网页源码,分析登录表单2. 使用python urllib2,cookielib 模拟网页登录import urllib,urllib2,cookielib#urllib2 支持 http,httpsdef loginWeb(...
分类:编程语言   时间:2014-09-26 18:08:38    阅读次数:202
python抓取网页信息
环境:python 2.7用自带的urllib,urllib2包可以实现大部分抓取功能。代码十分简短。关键在于正则表达式的建立和处理。 1 #coding=utf-8 2 ''' 3 Created on 2014-9-25 4 5 @author: Administrator 6 ''' 7 i....
分类:编程语言   时间:2014-09-25 11:29:58    阅读次数:197
python post上传文件
1.使用urllib2原始的方式import urllib2__author__ = 'huangjianan'def post_file(url,filepath,header): boundary = 'IYhWIT-aMbWSbS32CkryLCcV4lp-3N' #body ...
分类:编程语言   时间:2014-09-23 22:40:45    阅读次数:292
第6章 Web客户端访问
获取web页面#!/usr/bin/envpython importsys,urllib2 req=urllib2.Request(sys.argv[1]) fd=urllib2.urlopen(req) whileTrue: data=fd.read(1024) ifnotlen(data): break sys.stdout.write(data)首先建立了一个urllib2.Request对象,该对象用URL做参数。然后调用urlopen得到..
分类:Web程序   时间:2014-09-20 02:22:57    阅读次数:332
Python Requests库:HTTP for Humans
Python标准库中用来处理HTTP的模块是urllib2,不过其中的API太零碎了,requests是更简单更人性化的第三方库。用pip下载:pip install requests或者git:git clone git://github.com/kennethreitz/requests.git...
分类:编程语言   时间:2014-09-18 23:45:24    阅读次数:401
python 自动登录网页
语言:python浏览器:chrome工具:chrome控制台#!/usr/bin/python# coding: GBKimport urllib,urllib2,httplib,cookielibimport timeimport randomdef auto_login(url,name,pw...
分类:编程语言   时间:2014-09-16 13:59:30    阅读次数:228
900条   上一页 1 ... 82 83 84 85 86 ... 90 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!