URLlib2?

Discussion in 'Python' started by rodmc, Feb 28, 2008.

  1. rodmc

    rodmc Guest

    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
     
    rodmc, Feb 28, 2008
    #1
    1. Advertising

  2. rodmc

    Jarek Zgoda Guest

    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: | voice: +48228430101

    "We read Knuth so you don't have to." (Tim Peters)
     
    Jarek Zgoda, Feb 28, 2008
    #2
    1. Advertising

  3. rodmc

    Steve Holden Guest

    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/
     
    Steve Holden, Feb 28, 2008
    #3
  4. rodmc

    Jarek Zgoda Guest

    Steve Holden 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.


    Right, perfectly valid assumption. ;)

    I am bit too defensive today.

    --
    Jarek Zgoda
    Skype: jzgoda | GTalk: | voice: +48228430101

    "We read Knuth so you don't have to." (Tim Peters)
     
    Jarek Zgoda, Feb 28, 2008
    #4
  5. rodmc

    Bryan Olson Guest

    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.
     
    Bryan Olson, Feb 28, 2008
    #5
  6. rodmc

    Bryan Olson Guest

    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
     
    Bryan Olson, Feb 28, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kylotan

    urllib2 for HTTPS/SSL

    Kylotan, Jul 8, 2003, in forum: Python
    Replies:
    5
    Views:
    576
    Jeremy Hylton
    Jul 9, 2003
  2. John J. Lee

    Re: urllib2 http status

    John J. Lee, Jul 29, 2003, in forum: Python
    Replies:
    1
    Views:
    2,565
    rosendo
    Jul 31, 2003
  3. O. Koch

    FTP with urllib2 behind a proxy

    O. Koch, Aug 7, 2003, in forum: Python
    Replies:
    4
    Views:
    1,327
    John J. Lee
    Aug 14, 2003
  4. Clarence Gardner

    urllib2

    Clarence Gardner, Aug 8, 2003, in forum: Python
    Replies:
    1
    Views:
    431
    Clarence Gardner
    Aug 8, 2003
  5. Josef Cihal
    Replies:
    0
    Views:
    831
    Josef Cihal
    Sep 5, 2005
Loading...

Share This Page