Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > referer url

Reply
Thread Tools

referer url

 
 
pavloutefkros@gmail.com
Guest
Posts: n/a
 
      01-28-2008
Hello all!

I was wondering, if there is a way to retrieve the referer url with
python (web-based).
I tried this:

import os
print os.getenv('HTTP_REFERER')

but it's not working, even thought other http variables do function,
this one is always a None.

Thanks in advance.
 
Reply With Quote
 
 
 
 
Tim Chase
Guest
Posts: n/a
 
      01-28-2008
> I was wondering, if there is a way to retrieve the referer url with
> python (web-based).
> I tried this:
>
> import os
> print os.getenv('HTTP_REFERER')
>
> but it's not working, even thought other http variables do function,
> this one is always a None.


This could be for any number of reasons, inter alia:

1) you don't specify the environment in which your python code is
running. this may not get stashed in the os.getenv(). In
Django, it's stashed in request.META.HTTP_REFERER; in CGI, it
should be in your os.getenv(); in WebStack, the trans parameter
has get_headers()/get_header_values() methods you can use to
extract the referer; and in other frameworks, they may toss them
elsewhere.

2) the browser is configured to protect the privacy of the
browser, and not send a Referer header

3) your server may not be configured to include the HTTP_REFERER
environment variable (improbable, but possible)

4) your user(s) are coming from a book-marked link where there is
no Referer to be sent

-tkc


 
Reply With Quote
 
 
 
 
pavloutefkros@gmail.com
Guest
Posts: n/a
 
      01-28-2008
Thanks for the reply.
1) CGI so i'm doing it right.
2) this is impossible as i'm doing the exact same thing with another
language and it utterly works.
3) the same as above
4) no..

this gets nerve breaking!
 
Reply With Quote
 
Tim Chase
Guest
Posts: n/a
 
      01-28-2008
> 1) CGI so i'm doing it right.

that's helpful to know

> 2) this is impossible as i'm doing the exact same thing with another
> language and it utterly works.


Just making sure...same browser/setup/configuration, different
language?

> 3) the same as above


kinda figured...most servers give you the HTTP_REFERER, so you'
have to

> 4) no..
>
> this gets nerve breaking!


Well, you can always dump the contents of os.environ into your
output to see if you can find why.

from cgi import escape
out.write('<br>'.join([
'<b>%s:</b>%s' % (escape(k), escape(v))
for k,v in os.environ.iteritems()
])

-tkc




 
Reply With Quote
 
pavloutefkros@gmail.com
Guest
Posts: n/a
 
      01-28-2008
Thanks for that! i found the variable in "ALL_HTTP" and it's working
now.
Thanks again..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL-Rewriting, referer and https sameergn@gmail.com Java 3 07-11-2007 06:43 AM
AwStats vs. window.locate - why AwStats can''t get URL referer? meucat Javascript 0 09-07-2006 03:10 AM
Is there any way to make destination URL see a different referer? Chris Ianson HTML 1 04-01-2006 08:04 AM
ImageIO: Read JPG image from URL with header: referer? Rune Java 4 02-16-2005 01:08 PM
Re: How to Spoof Referer URL dave wanta ASP .Net 1 07-07-2003 07:46 AM



Advertisments