Results 1 to 12 of 12
  1. #1
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    2,419
    I'll show my weakness in scripting by asking how can I extract the particular query string that a user came in my site with.

    I know it can be done and have seen it but I looked around briefly and couldn't find it.

    If anyone would share the info I'd appreciate it.

    Thanks a bunch!

    ===============================
    PeePee merchants with PooPoo policies allow our earnings to be flushed down the crapper.

    Why give parasites unlimited cookie durations and credit for sales where they divert our users and overwrite our cookies. PP merchants directly support what many consider unfair trade practices and thievery!
    ===============================

  2. #2
    Full Member c4's Avatar
    Join Date
    January 18th, 2005
    Posts
    488
    Ok, this is some Perl code I came up with. You will have to use SSI or Javascript to get it working in your page.

    If you don't know what to do with it PM me and explain what exactly are you trying to do, I'll give you a hand ... or a script

    Regards


    #!/usr/bin/perl

    # Get the HTTP referer
    $referer = $ENV{'HTTP_REFERER'};

    # If the referer is blank or not set exit the script
    unless ($referer) {
    print "Content-type: text/html\n\n";
    print "No HTTP referer. Exiting...\n";
    exit;
    }

    # Get everything after "?" in the URL and store it in variable $buffer
    $referer =~ /([^\?]*)\?(.*)/;
    $buffer=$2;

    # Do some magic :-)
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $name =~ tr/+/ /;
    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $query{$name} = $value;
    }

    # Find the value you are looking for
    # If query is set to "myquery=XXYY" the value will be "XXYY"
    $this_is_what_i_search = $query{'myquery'};

    # Do whatever you want with it ...


    # Exit the script and print some HTML to avoid errors
    print "Content-type: text/html\n\n";
    print "Done\n";
    exit;



    YOURsoft affiliate software
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    A good parasite is a dead parasite. Screw it up and you're screwed!
    Save your affiliate program, save your earnings; Fight ParasiteWare™!
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  3. #3
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    594
    c4 assumed perl, is that your language of choice poon?

    IamJaloppy

  4. #4
    Full Member c4's Avatar
    Join Date
    January 18th, 2005
    Posts
    488
    c4 assumed Perl because this is c4's language of choice, I don't think poon has a language of choice or he wouldn't be asking this

    One thing though: the way I understand you want to get the query from the REFERRING page, not from the page the user is actually on right now (if the second is right, the code above could be very simplified). And I assumed your site uses HTML pages (with .htm(l) extensions), not .cgi/.php/.asp.


    Still I'd love to see some PHP code posted here that does the same thing as my code above (extracts query from REFERRING page), just curious how it's done in PHP.

    Regards



    YOURsoft affiliate software
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    A good parasite is a dead parasite. Screw it up and you're screwed!
    Save your affiliate program, save your earnings; Fight ParasiteWare™!
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  5. #5
    Just Lurking
    Join Date
    January 18th, 2005
    Posts
    1,263
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>$_SERVER['QUERY_STRING']

    The query string, if any, via which the page was accessed.<HR></BLOCKQUOTE>

    PHP if that helps. Notice it's a $_SERVER variable so you may or may not have it on your server. (You proably do thought.)

  6. #6
    Full Member
    Join Date
    January 18th, 2005
    Posts
    400
    Hey Happypoon,

    I might be missing the boat on this post or question...

    But would'nt it just be easier to use a good tracking system where you can easily click a few buttons and see what search queries peoplea are using to find your site.

    This is by far the most important piece of date that is collected by the "web stats package" and I would be lost with out it!

    I use a a third party tracking company that is a bit expensive but well worth it. You can easily track any and all stats including search refferals.

    www.hitslink.com

    Brian

    Brian Johnson
    Seek and you shall find

  7. #7
    Full Member c4's Avatar
    Join Date
    January 18th, 2005
    Posts
    488
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by Buddha:
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>$_SERVER['QUERY_STRING']

    The query string, if any, via which the page was accessed.<HR></BLOCKQUOTE>

    PHP if that helps. Notice it's a $_SERVER variable so you may or may not have it on your server. (You proably do thought.)<HR></BLOCKQUOTE>


    That's not the referring page, it's the actual page ($ENV{'QUERY_STRING'} in Perl).



    @Happypoon - please clarify this:
    - do you want to get query from REFERRING page or ACTUAL page? If you're going for SE keywords you'll have to use referring page not QUERY_STRING.

    - do you want to get the whole query (first=asfdasf&second=blablabla&third=xxyy&...) or just a part of it (second=blablabla)?


    I think if you tell us what you want to do it will be easier to give you the simplest example.


    Regards



    YOURsoft affiliate software
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    A good parasite is a dead parasite. Screw it up and you're screwed!
    Save your affiliate program, save your earnings; Fight ParasiteWare™!
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  8. #8
    Just Lurking
    Join Date
    January 18th, 2005
    Posts
    1,263
    Why not use AwStats or some other log processor?

  9. #9
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    2,419
    This is not for logging! I want to have access to the search string so I can dynamically write out the search string text in the html shown to the user.

    I know how to do the dhtml writting of the text but have no idea how to obtain the search criteria entered by a user.

    ===============================
    PeePee merchants with PooPoo policies allow our earnings to be flushed down the crapper.

    Why give parasites unlimited cookie durations and credit for sales where they divert our users and overwrite our cookies. PP merchants directly support what many consider unfair trade practices and thievery!
    ===============================

  10. #10
    Full Member c4's Avatar
    Join Date
    January 18th, 2005
    Posts
    488
    You mean the search string from referring SE or from search function on your site?



    YOURsoft affiliate software
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    A good parasite is a dead parasite. Screw it up and you're screwed!
    Save your affiliate program, save your earnings; Fight ParasiteWare™!
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  11. #11
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    2,419
    The search string from the se.

    Hows this for being explicit.

    A users searchs for "widget a" and clicks on a link where I promote product details for "widget a" from "merchant a". I also have a relationship with merchant b who also has a "widget a". Merchant A's widgets are high priced but much better quality while merchant b's prices are lower price but lower quality.

    Merchant B has a search box and merchant b's search box is shown along with product details from merchant a. What I want to do is to show the normal html page outlining merchant A's product that the user initially clicked on but interpret the search engine strings the user came to the site with and dynamically write out the serach box portion of the page for merchant b pre-populated with the same search string they entered my site with.

    If the user is turned off by the high price of "merchant a" there is another option for them already populated with the search string for merchant b on the page that is displayed that the user can click on to see additional options (if they want).
    ===============================
    PeePee merchants with PooPoo policies allow our earnings to be flushed down the crapper.

    Why give parasites unlimited cookie durations and credit for sales where they divert our users and overwrite our cookies. PP merchants directly support what many consider unfair trade practices and thievery!
    ===============================

    [This message was edited by happypoon on September 23, 2003 at 10:12 PM.]

    [This message was edited by happypoon on September 23, 2003 at 10:13 PM.]

  12. #12
    Full Member c4's Avatar
    Join Date
    January 18th, 2005
    Posts
    488
    You should have posted like this the first time, clears up things and would save many posts Programmer needs to know exactly what you are trying to do, small changes or if something is not clear can have a dramatic effect on the code...

    Anyway: sure it can be done, I've already got a solution in my mind. Just tell me something: do you use plain HTML pages (.htm, .html), server-parsed pages (.shtm, .shtml) or some scripting pages (.php, .cgi, .asp)? I'm asking because it will make a big difference how to implement it in your site!

    Regards



    YOURsoft affiliate software
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    A good parasite is a dead parasite. Screw it up and you're screwed!
    Save your affiliate program, save your earnings; Fight ParasiteWare™!
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  13. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. OR / AND in Search Strings
    By dssc in forum GoldenCAN
    Replies: 0
    Last Post: October 29th, 2007, 07:12 PM
  2. Extracting WMV3 Screenshots with FFmpeg
    By Snib in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: October 18th, 2005, 03:25 AM
  3. Extracting data from emails
    By munizjm in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: December 31st, 2003, 01:49 PM
  4. Tips For Extracting Payment
    By Tiebreaker in forum Midnight Cafe'
    Replies: 6
    Last Post: July 29th, 2003, 03:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •