473,386 Members | 1,712 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,386 software developers and data experts.

referer url

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.
Jan 28 '08 #1
4 6638
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
Jan 28 '08 #2
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!
Jan 28 '08 #3
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


Jan 28 '08 #4
Thanks for that! i found the variable in "ALL_HTTP" and it's working
now.
Thanks again..
Jan 28 '08 #5

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

Similar topics

5
by: Joshua Beall | last post by:
Hi All, I do web design for some small organizations, and one of the sites I have set up takes online conference registrations. Now, most of the time it works. In fact, every time I try it, it...
1
by: jawahar rajan | last post by:
All, I have a question about the Max Referer length. By default this is 256 I am not fully sure I understand this property. It this a header that is sent back to the Server by a client and is it...
2
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect...
3
by: exxos | last post by:
Hi all, I'm trying to list to a html page where the referer is, There are a lot of ways ive tried and work, but the problem if my mainpage uses frames, and no matter where I do the referer check...
3
by: Giuseppe | last post by:
I need to make a little software to know how many visitors see my websites, and where they come from. So I've added this code at the end of a webpage: <!------- Begin Stat code ------------->...
1
by: Raed Sawalha | last post by:
Hello: In my aspx page I need to check the HTTP_REFERER for (images swf ) file, so when I request the server variable (HTTP_REFERER) like this Request.ServerVariables within (page.aspx) . if the...
4
by: Raed Sawalha | last post by:
Dear : In my web page I'm always checking the referer page if it was empty I do something else also I do something :0). the problem in my ASPX page client side I did a popup window, and when...
1
by: Al | last post by:
Hi i'm having troble with a script where i check referer, on a PC with Zone Alarm Pro the referer isn't send... i did a couple of page of testing and no referer is sand, closing ZAP the...
9
by: xiaojunfei | last post by:
Hello,everybody. This is my simple code(C#): string str="http://www.cba.com"; object miss=null; object head="Referer:http://www.abc.com\r\n"; Axwebbrowser1.Navigate(str,ref miss,ref miss,ref...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.