当前位置: 首页>>代码示例>>Python>>正文


Python HTTP.getreply方法代码示例

本文整理汇总了Python中httplib.HTTP.getreply方法的典型用法代码示例。如果您正苦于以下问题:Python HTTP.getreply方法的具体用法?Python HTTP.getreply怎么用?Python HTTP.getreply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在httplib.HTTP的用法示例。


在下文中一共展示了HTTP.getreply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checkURL

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def checkURL(url):
	p = urlparse(url)
	h = HTTP(p[1])
	h.putrequest('HEAD', p[2])
	h.endheaders()
	print h.getreply()
	if h.getreply()[0] == 200: return 1
	else: return 0
开发者ID:yellowskyscraper,项目名称:Experiments,代码行数:10,代码来源:testFailThrough.py

示例2: check_url

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def check_url(url):
    p = urlparse(url)
    h = HTTP(p[1])
    h.putrequest('HEAD', p[2])
    h.endheaders()
    print h.getreply()[0]
    if h.getreply()[0] == 200: return True
    else: return False                                    
开发者ID:htccsautotest,项目名称:pi_testng,代码行数:10,代码来源:testopia_util.py

示例3: gethttpfile

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def gethttpfile(url, size=1024*1024):
  from urllib import splithost
  from httplib import HTTP
  if not url.startswith('http:'):
    raise ValueError, "URL %s" % url
  host, selector = splithost(url[5:])
  h = HTTP(host)
  h.putrequest('GET', url)
  h.endheaders()
  h.getreply()
  res = h.getfile().read(size)
  h.close()
  return res
开发者ID:ddxofy,项目名称:hda-analyzer-mb52,代码行数:15,代码来源:hda_analyzer.py

示例4: checkLink

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
	def checkLink(self, url):
		parsedURL = urlparse(url)
		httpConn = HTTP(parsedURL[1])
		httpConn.putrequest('HEAD',parsedURL[2])
		httpConn.endheaders()
		if httpConn.getreply()[0] == 200: return 1
		else: return 0
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:9,代码来源:checkversions.py

示例5: doLookup

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def doLookup(cellId, lac, host="www.google.com", port=80):
    from string import replace
    from struct import unpack
    page = "/glm/mmap"
    http = HTTP(host, port)
    result = None
    errorCode = 0

    content_type, body = encode_request(cellId, lac)
    http.putrequest('POST', page)
    http.putheader('Content-Type', content_type)
    http.putheader('Content-Length', str(len(body)))
    http.endheaders()
    http.send(body)
    errcode, errmsg, headers = http.getreply()
    result = http.file.read()
    # be nice to the web service, will not pause on memoized coordinates
    time.sleep(0.75)
    # could need some modification to get the answer: here I just need
    # to get the 5 first characters
    if (errcode == 200):
        (a, b, errorCode, latitude, longitude, c, d, e) = unpack(">hBiiiiih",result)
        latitude = latitude / 1000000.0
        longitude = longitude / 1000000.0
    return latitude, longitude
开发者ID:geexercise,项目名称:cellocate,代码行数:27,代码来源:cellocate.py

示例6: URL_exists

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def URL_exists(url):
    verbose = True
    
    ''' Checks that a URL exists (answer != 404) and returns the size.
    
    Returns None if does not exists, the size in bytes otherwise.
     ''' 
    if verbose:
        sys.stderr.write('Checking %s ' % url)
     
    p = urlparse(url) 
    h = HTTP(p[1]) 
    h.putrequest('HEAD', p[2]) 
    h.endheaders() 
    
    code, status, message = h.getreply() #@UnusedVariable

    if verbose:
        sys.stderr.write('\t%d\n' % code)
    
    
    if code == 404: 
        return None
    else: 
        return int(message['content-length'])
开发者ID:AndreaCensi,项目名称:be1008,代码行数:27,代码来源:be_materials.py

示例7: urlcheck

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def urlcheck(url):
   u = urlparse(url)
   h = HTTP(u.geturl())
   print u.geturl()
   h.putrequest('HEAD',u.geturl())
   h.endheaders()
   r = h.getreply()
   return isvalid(r)
开发者ID:abishop42,项目名称:sample,代码行数:10,代码来源:validate.py

示例8: URL_exists

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def URL_exists(url): 
	p = urlparse(url) 
	h = HTTP(p[1]) 
	h.putrequest('HEAD', p[2]) 
	h.endheaders() 
	if h.getreply()[0] == 200: 
		return True 
	else:
		return False 
开发者ID:emonson,项目名称:CopyrightScripts,代码行数:11,代码来源:get_french_copyright_docs.py

示例9: grab_information

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def grab_information(cid, lac, mnc=0, mcc=0):

	country = country_iso(mcc)

	v("Fetching latitude and longitude...")
	query = pack('>hqh2sh13sh5sh3sBiiihiiiiii',
		21, 0,
		len(country), country,
		len(__DEVICE__), __DEVICE__,
		len('1.3.1'), "1.3.1",
		len('Web'), "Web",
		27, 0, 0,
		3, 0, int(cid), int(lac), 0, 0, 0, 0)


	http = HTTP('www.google.com', 80)
	http.putrequest('POST', '/glm/mmap')
	http.putheader('Content-Type', 'application/binary')
	http.putheader('Content-Length', str(len(query)))
	http.endheaders()
	http.send(query)
	code, msg, headers = http.getreply()
	result = http.file.read()
 
	try:
		(a, b,errorCode, lat, lon, cov, d, e) = unpack(">hBiiiiih",result)
	except:
		a = 0
		b = 0
		errorCode = 0
		lat = 0
		lon = 0
		cov = 0
		d = 0
		e = 0
		pass

	v("a=%s, b=%s, errorCode=%s, cov=%s, d=%s, e=%s" % (str(a), str(b), errorCode, str(cov), str(d), str(e)))
	lat = lat / 1000000.0
	lon = lon / 1000000.0
	v("Here we go: %s and %s" % (lat, lon))
	


	geo_info = None
	geo_info_json = None
	geo_info = grab_geo_info(lat, lon)
	geo_info = grab_geo_info(-8.064159, -34.896666)
	print str(geo_info)
	geo_info_json = json.loads(geo_info)

	v("Geo Info: %s" % geo_info)
	v("Geo Info: %s" % str(geo_info_json))

	c = Cell(geo_info_json, lat, lon, cov)

	return c
开发者ID:LucaBongiorni,项目名称:cell-locator,代码行数:59,代码来源:celllocator.py

示例10: get_redirect_url

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def get_redirect_url(url):
    types = urllib.splittype(url)
    host, res = urllib.splithost(types[1])
    h = HTTP()
    h.connect(host)
    h.putrequest('HEAD', res)
    h.endheaders()
    status, reason, headers = h.getreply()
    return headers['location']
开发者ID:games,项目名称:py-onecore,代码行数:11,代码来源:downloader.py

示例11: get_file_size

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def get_file_size(url):
    types = urllib.splittype(url)
    host, res = urllib.splithost(types[1])
    h = HTTP()
    h.connect(host)
    h.putrequest('HEAD', res)
    h.putheader('Host', host)
    h.endheaders()
    status, reason, headers = h.getreply()
    return float(headers['Content-Length'])
开发者ID:games,项目名称:py-onecore,代码行数:12,代码来源:downloader.py

示例12: fetch_latlong_http

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def fetch_latlong_http(query):
    http = HTTP("www.google.com", 80)
    http.putrequest("POST", "/glm/mmap")
    http.putheader("Content-Type", "application/binary")
    http.putheader("Content-Length", str(len(query)))
    http.endheaders()
    http.send(query)
    code, msg, headers = http.getreply()
    result = http.file.read()
    return result
开发者ID:321cyb,项目名称:small-projects,代码行数:12,代码来源:glm.py

示例13: fetch_latlong_http

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
	def fetch_latlong_http(self, query):
	    http = HTTP('www.google.com', 80)
	    http.putrequest('POST', '/glm/mmap')
	    http.putheader('Content-Type', 'application/binary')
	    http.putheader('Content-Length', str(len(query)))
	    http.endheaders()
	    http.send(query)
	    code, msg, headers = http.getreply()
	    result = http.file.read()
	    return result
开发者ID:oulix,项目名称:shake4one,代码行数:12,代码来源:class.py

示例14: identify

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def identify(host):
    h = HTTP(host)
    h.putrequest('GET', 'http://%s/' % host)
    h.putheader('Accept', '*/*')
    h.endheaders()
    errcode, errmsg, response = h.getreply()
    h.close()
    patterns.attempts = response.headers
    try: str = response['server']
    except: str = None
    return (str, None)
开发者ID:bruceg,项目名称:siteinfo,代码行数:13,代码来源:http.py

示例15: action_delete

# 需要导入模块: from httplib import HTTP [as 别名]
# 或者: from httplib.HTTP import getreply [as 别名]
def action_delete():
    vip = sys.argv[3]
    h = HTTP('home.shaunkruger.com:8087')
    h.putrequest('DELETE','/module/mod_cluster_admin/vip/'+vip)
    h.putheader('Authorization','Basic '+base64.standard_b64encode('skruger:testing'))
    h.endheaders()
    errcode, errmsg, headers = h.getreply()
    if errcode == 200:
         f = h.getfile()
         print f.read()
    return
开发者ID:alepharchives,项目名称:Surrogate-Interface,代码行数:13,代码来源:surrogate_cmd_vip.py


注:本文中的httplib.HTTP.getreply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。