473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

URLlib2?

Hi,

Probably a silly question but I am writing a CGI script which need to
check the referring URL, can anyone provide any pointers? I have
looked at URLLib2 and a couple of other libraries, but am slightly
confused.

Thanks in advance,
rod

Feb 28 '08 #1
4 1096
rodmc napisał(a):
Probably a silly question but I am writing a CGI script which need to
check the referring URL, can anyone provide any pointers? I have
looked at URLLib2 and a couple of other libraries, but am slightly
confused.
Using httplib you can issue HEAD request to check if it does not return
404 response, but this works only with HTTP/HTTPS urls.

--
Jarek Zgoda
Skype: jzgoda | GTalk: zg***@jabber.aster.pl | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)
Feb 28 '08 #2
Jarek Zgoda wrote:
rodmc napisał(a):
>Probably a silly question but I am writing a CGI script which need to
check the referring URL, can anyone provide any pointers? I have
looked at URLLib2 and a couple of other libraries, but am slightly
confused.

Using httplib you can issue HEAD request to check if it does not return
404 response, but this works only with HTTP/HTTPS urls.
It's unlikely that any other type of URL would result in the browser
sending a "Referer:" header.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Feb 28 '08 #3
rodmc wrote:
Probably a silly question but I am writing a CGI script which need to
check the referring URL, can anyone provide any pointers? I have
looked at URLLib2 and a couple of other libraries, but am slightly
confused.
When you say, "check the referring URL," what are checking about
it? Do you just want to know from where your users came? C.l.p is
one of Usenet's more helpful groups, but you have to clear and
exact, or we're likely to correctly answer the wrong question.
One reason that web sites check referring URL's is to try to
ensure that client went through the site's intended path. The
site might want to make sure users saw the terms-and-condition,
or stop other sites from "deep linking", or prevent so-called
"bandwidth theft". In these cases, checking the referrer is a
weak solution. There is a much better method based on cookies,
which all the popular browsers now support.

Feb 28 '08 #4
rodmc wrote:
Probably a silly question but I am writing a CGI script which need to
check the referring URL, can anyone provide any pointers? I have
looked at URLLib2 and a couple of other libraries, but am slightly
confused.
When you say, "check the referring URL," what are checking about
it? Do you just want to know from where your users came? C.l.p is
one of Usenet's more helpful groups, but you have to clear and
exact, or we're likely to correctly answer the wrong question.

There are many plausible checks one might apply to the referring
URL. Some are trivial, some subtle.

One reason that web servers check referring URL's is to try to
ensure that clients go through the intended path. Perhaps the
site simply wants to make sure users see teh terms-and-conditions,
but more commonly it wants to stop other sites from "deep
linking", or thwart so-called "bandwidth theft". In these cases,
checking the referrer is a weak solution; the better method is
based on cookies.
--
--Bryan
Feb 28 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
1
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...
2
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...
5
by: Pascal | last post by:
Hello, I want to acces my OWA (Outlook Web Acces - http Exchange interface) server with urllib2 but, when I try, I've always a 401 http error. Can someone help me (and us)? Thanks. ...
0
by: jacob c. | last post by:
When I request a URL using urllib2, it appears that urllib2 always makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use the "If-None-Match"/"ETag" HTTP headers to conserve...
0
by: Gil Tal | last post by:
Hi, I use urllib2 to download a redirected url and I get an exception from the bowels of urllib2. It seems that urllib2 implements some super sophisticated self check and tries to control the...
1
by: Ray Slakinski | last post by:
Hello, I have defined a function to set an opener for urllib2, this opener defines any proxy and http authentication that is required. If the proxy has authencation itself and requests an...
0
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...
3
by: m.banaouas | last post by:
Hi all, I started to use urllib2 library and HTTPBasicAuthHandler class in order to authenticate with a http server (Zope in this case). I don't know why but it doesn't work, while authenticating...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.