We have a lot of simple code using 'urllib', that basically
just goes out and opens and read()'s some http url. Very basic,
ten line scripts, and they work fine with urllib.
We want to use urllib2 for everything, though, but when we
do we get:
page=urllib2.ur lopen("http://www.something.c om/whatever.php")
....
File "/usr/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/lib/python2.3/urllib2.py", line 463, in http_error_302
self.inf_msg + msg, headers, fp)
urllib2.HTTPErr or: HTTP Error 302: The HTTP server returned a redirect
error that would lead to an infinite loop.
The last 30x error message was:
Found
These redirect errors just don't happen with urrlib.urlopen( ), and I
can
only find a few posts on deja that even mention this problem. Is
there a known workaround?
Thanks,
J.D. 2 5483 dj********@yaho o.com (Jay Davis) writes: We have a lot of simple code using 'urllib', that basically just goes out and opens and read()'s some http url. Very basic, ten line scripts, and they work fine with urllib.
We want to use urllib2 for everything, though, but when we do we get:
[...] urllib2.HTTPErr or: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop. The last 30x error message was: Found
Which version of Python are you using?
It might also help if you can give a publicly-accessible URL that
triggers the problem (mail it to me privately if you prefer).
John jj*@pobox.com (John J. Lee) writes: dj********@yaho o.com (Jay Davis) writes:
We have a lot of simple code using 'urllib', that basically just goes out and opens and read()'s some http url. Very basic, ten line scripts, and they work fine with urllib.
We want to use urllib2 for everything, though, but when we do we get: [...] urllib2.HTTPErr or: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop. The last 30x error message was: Found
Which version of Python are you using?
It might also help if you can give a publicly-accessible URL that triggers the problem (mail it to me privately if you prefer).
Jay sent me a URL, and it turns out both urllib and urllib2 are
functioning as intended. There's a 302 loop caused by the server
expecting cookies to get returned. urllib goes into a loop until it
notices it's redirected 10 times, then just returns the 302 as a
normal response (which doesn't seem very nice, but appears to be what
was intended). urllib2 detects the loop and returns the 302 as an
HTTPError exception (which can be caught and .read() if necessary).
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bmiras |
last post by:
I've got a problem using urllib2 to get a web page.
I'm going through a proxy using user/password authentification
and i'm trying to get a page asking for a HTTP authentification.
And I'm using python 2.3
Here is an exemple of the piece of code I use:
import urllib2
#Proxy handler
proxy_handler = urllib2.ProxyHandler({"http" :
|
by: Matthew Wilson |
last post by:
I am writing a script to check on my router's external IP address. My
ISP refreshes my IP very often and I use dyndns for the hostname for my
computer. My Netgear mr814 router has a webserver that uses HTTP basic
authorization.
My script uses urllib2 to connect to the router and read the html page
with the current external IP address. This is the function I wrote to
lookup the router's external IP:
def mr814(router_user,...
|
by: John F Dutcher |
last post by:
Can anyone comment on why the code shown in the Python error is in
some way incorrect...or is there a problem with Python on my hoster's
site ??
The highlites don't seem to show here...but line #80 and line # 38 are
the first line offenders.
--> --> -->
|
by: Matt |
last post by:
I'm trying to get the HTML data off of a webpage. Let's say for the
sake of argument it's the python homepage. I've googled around and
found some examples that people said worked. Here's what I've cobbled
together:
#getHTML.py
############################################
import urllib
import urllib2
proxy_info = {'user':'us3r',
|
by: Ali.Sabil |
last post by:
hello all,
I just maybe hit a bug in both urllib and urllib2, actually urllib
doesn't support proxy authentication, and if you setup the http_proxy
env var to http_proxy=http://user:passwd@host:port/ and
https_proxy=$http_proxy i get a traceback :
Traceback (most recent call last):
File "test_urllib.py", line 2, in ?
urllib.urlopen("https://sf.net/")
| |
by: Alessandro Fachin |
last post by:
I write this simply code that should give me the access to private page with
htaccess using a proxy, i don't known because it's wrong...
import urllib,urllib2
#input url
url="http://localhost/private/file"
#proxy set up
|
by: rplobue |
last post by:
im trying to get urllib2 to work on my server which runs python
2.2.1. When i run the following code:
import urllib2
for line in urllib2.urlopen('www.google.com'):
print line
i will always get the error:
|
by: est |
last post by:
A simple py script
import urllib2
req=urllib2.Request("http://www.google.com")
req.set_proxy("127.0.0.1:1","http")
print urllib2.urlopen(req).read()
|
by: Magnus.Moraberg |
last post by:
Hi,
I have the following code -
import urllib2
from BeautifulSoup import BeautifulSoup
proxy_support = urllib2.ProxyHandler({"http":"http://
999.999.999.999:8080"})
opener = urllib2.build_opener(proxy_support)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |