httplib2

“ImportError: No module named httplib2” even after installation

不羁岁月 提交于 2019-11-27 13:04:07
I'm having a hard time understanding why I get ImportError: No module named httplib2 after making sure httplib2 is installed. See below: $ which -a python /usr/bin/python /usr/local/bin/python $ pip -V pip 1.4.1 from /usr/local/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7 $ pip list google-api-python-client (1.2) httplib2 (0.8) pip (1.4.1) pudb (2013.5.1) Pygments (1.6) setuptools (1.3.2) wsgiref (0.1.2) $ pip install httplib2 Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/local/lib/python2.7/site-packages Cleaning up... $ python Python 2.7.5 (default

How do I get the IP address from a http request using the requests library?

ぐ巨炮叔叔 提交于 2019-11-27 12:26:57
I am making HTTP requests using the requests library in python, but I need the ip address from the server that responded the http request and I'm trying to avoid to make two calls (and possibly having a different ip address from the one that responded the request. Is that possible? Does any python http library allows me to do that? ps: I also need to make HTTPS requests and to use an authenticated proxy. Update 1: Example: import requests proxies = { "http": "http://user:password@10.10.1.10:3128", "https": "http://user:password@10.10.1.10:1080", } response = requests.get("http://example.org",

104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?

别来无恙 提交于 2019-11-27 06:49:09
We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the size of the OAuth header, the request is split into two packets. The service responds to both with ACK The service sends the response, one packet per header (HTTP/1.0 200 OK, then the Date header, etc.). The client responds to each with ACK. (Good request) the server

how to follow meta refreshes in Python

放肆的年华 提交于 2019-11-27 05:18:18
Python's urllib2 follows 3xx redirects to get the final content. Is there a way to make urllib2 (or some other library such as httplib2 ) also follow meta refreshes ? Or do I need to parse the HTML manually for the refresh meta tags? asmaier Here is a solution using BeautifulSoup and httplib2 (and certificate based authentication): import BeautifulSoup import httplib2 def meta_redirect(content): soup = BeautifulSoup.BeautifulSoup(content) result=soup.find("meta",attrs={"http-equiv":"Refresh"}) if result: wait,text=result["content"].split(";") if text.strip().lower().startswith("url="): url

“ImportError: No module named httplib2” even after installation

六月ゝ 毕业季﹏ 提交于 2019-11-26 13:56:03
问题 I'm having a hard time understanding why I get ImportError: No module named httplib2 after making sure httplib2 is installed. See below: $ which -a python /usr/bin/python /usr/local/bin/python $ pip -V pip 1.4.1 from /usr/local/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7 $ pip list google-api-python-client (1.2) httplib2 (0.8) pip (1.4.1) pudb (2013.5.1) Pygments (1.6) setuptools (1.3.2) wsgiref (0.1.2) $ pip install httplib2 Requirement already satisfied (use --upgrade to

104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?

混江龙づ霸主 提交于 2019-11-26 12:11:12
问题 We\'re developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, \'Connection reset by peer\') When I listen in with wireshark, the \"good\" and \"bad\" responses look very similar: Because of the size of the OAuth header, the request is split into two packets. The service responds to both with ACK The service sends the response, one packet per header