#-*-coding:cp936-*-importurllib2importredefu(url):#connecttoaURLwebsite=urllib2.urlopen(url)#readhtmlcodehtml=website.read()#usere.findalltogetallthel...
分类:
编程语言 时间:
2014-12-05 12:27:16
阅读次数:
122
Python urllib模块urlopen()与urlretrieve()的使用方法详解。1.urlopen()方法urllib.urlopen(url[, data[, proxies]]) :创建一个表示远程url的类文件对象,然后像本地文件一样操作这个类文件对象来获取远程数据。参数url表示...
分类:
编程语言 时间:
2014-11-19 18:07:26
阅读次数:
186
# -*- coding:utf-8 -*-
import re,urllib,sys,os,time
def getAllUrl():
entry=sys.argv[1]
#try:
getPage=urllib.urlopen(entry).read()
#except:
# print "Error"
pattern=re.compile(r'')
web_site_p...
分类:
编程语言 时间:
2014-11-17 17:55:13
阅读次数:
304
用Python编一个抓网页的程序是非常快的,下面就是一个例子:import urllib2 html = urllib2.urlopen('http://blog.raphaelzhang.com').read()但是在实际工作中,这种写法是远远不够的,至少会遇到下面几个问题:网络会出错,任何错误都...
分类:
编程语言 时间:
2014-11-15 16:44:29
阅读次数:
535
1 # coding=gbk2 import sys,urllib.request,re3 4 url = "http://www.3322.org/dyndns/getip" #网页地址5 myPage=urllib.request.urlopen(url).read()6 myPage = my...
分类:
编程语言 时间:
2014-11-07 14:20:01
阅读次数:
238
以前的python2.x的时候:try:fp=urllib.request.urlopen(blogurl)exceptException,e:print(e)print('downloadexception%s'%blogurl)return0现在python3.x的时候:try:fp=urlli...
分类:
编程语言 时间:
2014-11-02 10:44:11
阅读次数:
209
#-*-coding:-utf-8importurllib#url='http://iplaypython.com/'#url1=urllib.urlopen(url)#打开url地址,urlopen(url,data=None,proxies=None)#printurl1.read()#读取re...
分类:
编程语言 时间:
2014-10-29 01:56:32
阅读次数:
323
第3关 ORZ,又是源代码。开启正则表达式。from urllib import *from urllib.request import *import reres = urlopen('http://www.pythonchallenge.com/pc/def/equality.html')li....
分类:
编程语言 时间:
2014-10-26 19:33:43
阅读次数:
215
用给自己记录用defmonitor_work_1(content):dict_1={‘service‘:‘rdc_monitor‘,‘checkpoint‘:‘rdc_monitor_log‘,‘title‘:content,‘content‘:content,‘cluster‘:‘public‘,‘grade‘:‘2‘}params=urllib.urlencode(dict_1)urllib.urlopen(‘http://alert.sae.sina.com.cn/new/‘,params)
分类:
Web程序 时间:
2014-10-21 19:49:41
阅读次数:
168
I would like to retrieve the content of a url. Similar to pythons:html_content = urllib.urlopen("http://www.test.com/test.html").read()In examples(jav...
分类:
Web程序 时间:
2014-10-18 15:21:48
阅读次数:
232