Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53000 > unrolled thread

Getting request's source site

Started byGuy Tamir <guytamir1@gmail.com>
First post2013-08-26 06:10 -0700
Last post2013-08-27 19:36 +1000
Articles 7 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  Getting request's source site Guy Tamir <guytamir1@gmail.com> - 2013-08-26 06:10 -0700
    Re: Getting request's source site Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-26 14:25 +0000
      Re: Getting request's source site Guy Tamir <guytamir1@gmail.com> - 2013-08-26 08:03 -0700
        Re: Getting request's source site Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-26 11:16 -0400
        Re: Getting request's source site random832@fastmail.us - 2013-08-26 13:51 -0400
        Re: Getting request's source site Steven D'Aprano <steve@pearwood.info> - 2013-08-27 09:23 +0000
          Re: Getting request's source site Chris Angelico <rosuav@gmail.com> - 2013-08-27 19:36 +1000

#53000 — Getting request's source site

FromGuy Tamir <guytamir1@gmail.com>
Date2013-08-26 06:10 -0700
SubjectGetting request's source site
Message-ID<6dc9b8f6-7eb7-42a3-b3ea-ccc3aef072ee@googlegroups.com>
Hi all,

I was wondering how i can get the source from which the request came from.
If a user posted a link that directs to my server on facebook i'd like to know that a specific click was from facebook or twitter etc..

Thanks

[toc] | [next] | [standalone]


#53002

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-26 14:25 +0000
Message-ID<521b656d$0$29986$c3e8da3$5496439d@news.astraweb.com>
In reply to#53000
On Mon, 26 Aug 2013 06:10:41 -0700, Guy Tamir wrote:

> Hi all,
> 
> I was wondering how i can get the source from which the request came
> from. If a user posted a link that directs to my server on facebook i'd
> like to know that a specific click was from facebook or twitter etc..

That would be the "referer" header in the HTTP request. (Note that it is 
an accidental misspelling of "referrer".) Including a referrer is not 
compulsory, so be prepared for it not to be available.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53003

FromGuy Tamir <guytamir1@gmail.com>
Date2013-08-26 08:03 -0700
Message-ID<03e29dbb-d95d-495e-8937-2b630897d36b@googlegroups.com>
In reply to#53002
On Monday, August 26, 2013 5:25:49 PM UTC+3, Steven D'Aprano wrote:
> On Mon, 26 Aug 2013 06:10:41 -0700, Guy Tamir wrote:
> 
> 
> 
> > Hi all,
> 
> > 
> 
> > I was wondering how i can get the source from which the request came
> 
> > from. If a user posted a link that directs to my server on facebook i'd
> 
> > like to know that a specific click was from facebook or twitter etc..
> 
> 
> 
> That would be the "referer" header in the HTTP request. (Note that it is 
> 
> an accidental misspelling of "referrer".) Including a referrer is not 
> 
> compulsory, so be prepared for it not to be available.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Thanks for reply,
In what cases will i have this header? is there something i can do to enforce having it?
Are there any other ways?

[toc] | [prev] | [next] | [standalone]


#53005

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-08-26 11:16 -0400
Message-ID<mailman.238.1377530170.19984.python-list@python.org>
In reply to#53003
On Mon, Aug 26, 2013 at 11:03 AM, Guy Tamir <guytamir1@gmail.com> wrote:
> On Monday, August 26, 2013 5:25:49 PM UTC+3, Steven D'Aprano wrote:
>> On Mon, 26 Aug 2013 06:10:41 -0700, Guy Tamir wrote:
>>
>>
>>
>> > Hi all,
>>
>> >
>>
>> > I was wondering how i can get the source from which the request came
>>
>> > from. If a user posted a link that directs to my server on facebook i'd
>>
>> > like to know that a specific click was from facebook or twitter etc..
>>
>>
>>
>> That would be the "referer" header in the HTTP request. (Note that it is
>>
>> an accidental misspelling of "referrer".) Including a referrer is not
>>
>> compulsory, so be prepared for it not to be available.
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>> Steven
>
> Thanks for reply,
> In what cases will i have this header? is there something i can do to enforce having it?
> Are there any other ways?
> --

You can look in the server logs if you have them available.  If the
visitor supplied a referer value in the header, it will be in the log.
 You don't have any say in this from your end.

If you are the creator of your own website you might like to add
google analytics to your pages.  This is done with a little javascript
that google provides.

Although there may be a python angle to your question, it isn't apparent yet.


> http://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#53011

Fromrandom832@fastmail.us
Date2013-08-26 13:51 -0400
Message-ID<mailman.244.1377539494.19984.python-list@python.org>
In reply to#53003
On Mon, Aug 26, 2013, at 11:03, Guy Tamir wrote:
> Thanks for reply,
> In what cases will i have this header?

In practice, you'll usually have it, except in cases where the user has
bookmarked your site, typed/pasted the URL directly, had it opened by an
external program, or taken action to block referers from being sent
(this last one is uncommon)

> is there something i can do to
> enforce having it?

You can refuse to serve the content if it's not present. But this will
annoy users since they can't bookmark it or open it from an external
program.

[toc] | [prev] | [next] | [standalone]


#53043

FromSteven D'Aprano <steve@pearwood.info>
Date2013-08-27 09:23 +0000
Message-ID<521c700b$0$11100$c3e8da3@news.astraweb.com>
In reply to#53003
On Mon, 26 Aug 2013 08:03:33 -0700, Guy Tamir wrote:

[asking about Referer header]
> In what cases will i have this header? is there something i can do to
> enforce having it? Are there any other ways?

The Referer header is in the HTTP Request that is made to your server. 
What server are you using? If it is a custom server written in Python, 
then this is a legitimate question for this list. Otherwise, check the 
documentation for your server. Any decent web server will already deal 
with referrers, and any decent web analytics software will show you the 
information collected.

http://en.wikipedia.org/wiki/List_of_web_analytics_software


As for enforcing a referer, that's a really low, dirty thing to do, and I 
will not give you any hints as to how to do such a thing. Websites that 
take different actions depending on where you are coming from are the 
lowest of the low. Need a hand disposing of a body? Yeah, there are 
legitimate reasons for this, I'll help if I can. Forcing visitors to your 
website to set the Referer header? Nope, no way.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53045

FromChris Angelico <rosuav@gmail.com>
Date2013-08-27 19:36 +1000
Message-ID<mailman.261.1377596172.19984.python-list@python.org>
In reply to#53043
On Tue, Aug 27, 2013 at 7:23 PM, Steven D'Aprano <steve@pearwood.info> wrote:
> Need a hand disposing of a body? Yeah, there are
> legitimate reasons for this, I'll help if I can. Forcing visitors to your
> website to set the Referer header? Nope, no way.

Friends help friends move bodies. But even they don't help move headers.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web