import re
import urllib
import os
def rename(name):
name = name + '.jpg'
return name
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(ht...
分类:
编程语言 时间:
2015-01-30 09:08:37
阅读次数:
211
import urllibimport webbrowserurl ="http://www.baidu.com"content = urllib.urlopen(url).read()#print contentopen('e:/song.htm', 'w').write(content)webb...
分类:
编程语言 时间:
2015-01-26 01:14:20
阅读次数:
170
import urllib2import urllibcontent=urllib2.urlopen("http://www.cnblogs.com/sayary/archive/2013/03/11/2952638.html").read()##print content##href=conten...
分类:
Web程序 时间:
2015-01-12 14:33:56
阅读次数:
163
之前介绍了根据old_url获取真实url的geturl的方法,而根据urlopen返回的应答对象的info方法可以获取服务器发送头部headers的内容,并且通过字典形式反馈出来,同样测试代码如下: from urllib2 import Request, urlopenold_url = ...
分类:
Web程序 时间:
2014-12-26 18:16:57
阅读次数:
210
urllib:编码参数离不开urllib,urllib.urlencode,urllib.urlopen(URL,[,data])支持POST,根据参数区分post或者geturllib2:发送url请求,可添加http请求头字段,但是添加Cookie头字段无效httplib: 可以发送cookie...
分类:
Web程序 时间:
2014-12-22 10:59:52
阅读次数:
295
urllib官方文档地址 :https://docs.python.org/2/library/urllib.html
官网提供了 四个 访问的例子
GET 请求
import urllib
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen("http://www.mus...
分类:
编程语言 时间:
2014-12-18 15:20:29
阅读次数:
187
#-*- coding:utf-8 -*- import urllibimport threadingdef func(url): status = urllib.urlopen(url).code print status urlinfo = ['http://www.sohu...
分类:
编程语言 时间:
2014-12-17 09:42:56
阅读次数:
192
以下代码,在执行结果中的中文出现乱码。from bs4 import BeautifulSoupimport urllib2request = urllib2.Request('http://www.163.com')response = urllib2.urlopen(request)html_d...
分类:
Web程序 时间:
2014-12-16 16:30:13
阅读次数:
199
importurllib2,urllib,osdefUrl1(url,files):#try:url=urllib2.urlopen(url)except:return'error'fp=file(files,'w+')fp1=url.read()fp.write(fp1)fp.close()url...
分类:
编程语言 时间:
2014-12-09 17:16:25
阅读次数:
241