标签:python python get python get请求 python httplib2 请求
# -*- coding: utf-8 -*- try: import httplib2 except ImportError: print(‘错误:‘) print(‘ httplib2这个库没有找到,程序无法继续执行!‘) exit(255) def network_get_proc(self, use_cache = True): ‘‘‘POST动作‘‘‘ get_request_str = ‘http://192.168.0.54/softlist‘ # 请求URL # print(‘->%s‘ % post_request_str) if use_cache: h = httplib2.Http(‘.cache‘) else: h = httplib2.Http(‘no‐cache‘) if use_cache: response, content = h.request(get_request_str) else: response, content = h.request(get_request_str, headers={‘cache‐control‘:‘no‐cache‘}) print(‘->status:%d‘ % response.status) get_ret = False if response.status == 200: get_ret = True print(‘INFO:success!‘) print(‘***response***‘) print(response) print(‘***content***‘) print(content.decode(‘utf-8‘)) else: get_ret = False return get_ret # 应用程序入口 if __name__ == ‘__main__‘: post_ret = network_get_proc(False)
标签:python python get python get请求 python httplib2 请求
原文地址:http://blog.csdn.net/ccpw_cn/article/details/25337701