WEB more USERAGENT stuff

Discussion in 'OT Technology' started by MSTRMOO, Mar 2, 2009.

Thread Status:
Not open for further replies.
  1. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    i have found online that you can set the user agent using:

    ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');



    however, i dont know php too well and i am confused as to where this line of code should go... any ideas?
     
  2. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    <?php
    ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
    ?>

    ?
     
  3. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    doesnt do anything... i have it setup like this..

    www.site1.com/file.php

    <?php
    ini_set('user_agent', 'Mozilla/5.0TESTEST (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
    header( 'Location: http://www.site2.com/' ) ;
    ?>


    so it sets the useragent and then redirects..

    in this example, im assuming www.site2.com should record the user agent Mozilla/5.0TESTEST (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3

    but it does not..
     
  4. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    you can also just set this in your htaccess

    php_value user_agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
     
  5. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    i get Internal Server Error :o i think im placing it in the wrong place.. where should it go??

    # -FrontPage-
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName sy.com
    AuthUserFile /home/sy/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/sy/public_html/_vti_pvt/service.grp

    # BEGIN WordPress

    # END WordPress
     
  6. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
  7. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    also im not seeing a php.ini file for my wordpress blog..............
     
  8. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    dont they throw useragent cloaking under seo blackhat, just like ip cloaking
     
  9. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    not the point here...
     
  10. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
  11. ROFL

    ROFL New Member

    Joined:
    Dec 27, 2004
    Messages:
    6,862
    Likes Received:
    0
    Location:
    England
    Not sure if this is right but surely the User's own browser passes on their user agent. Setting the user agent for PHP will only work if your using PHP to grab content? But as the user is being forwarded to another page, it is the users user agent that will be registered, whether PHP is set to anything or not
     
  12. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    so what you are trying to scrape the site but dont want to make it obvious

    just use the curl example they posted on their site instead of redirecting users.

    and like rofl said, i dont think redirecting users after setting their user agent will work.
    when the new page loads, it'll just detect their useragent from there. what you have to look into (if possible) is forwarding that information to the next site. like posting it kind of.
     
  13. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    thanks.. it doesnt really matter where i replace the user agent, as long as it is something differing on www.site2.com ...

    i was trying to use the curl example but cant get it to work... maybe im using it in wrong place.. im using it in header.php of my wordpress blog.. and i get this


    Warning: curl_setopt(): supplied argument is not a valid cURL handle resource in /homepages/42/d256933267/htdocs/wp-content/themes/trance/header.php on line 3
     
  14. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    errr.. im pretty sure it an issue with $curl not being defined... but im so lost on how to do this...


    <?php

    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');

    ?>
     
  15. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    i got the error fixed with

    <?php

    $useragent="Mozilla/5.0 (testsetsetWindows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

    ?>


    however its still not changing the useragent.. where should this script be palceD?
     
  16. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    yeah youre supposed to use the curl to grab the site you want to scrape.

    put in the rest of the curl shit (http://forums.offtopic.com/showthread.php?t=4124695)

    what it'll do is grab everything from that site (scrape) and should put the refferer on that site, that you have a user agent of whatever.

    that is of course if you're trying to scrape a site like what that site you linked me to was referring to.
     
  17. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    man... i dont get it :o... really i dont know php lol
     
  18. hank85

    hank85 sudo shred /dev/sda -f -v -z --iterations=6

    Joined:
    Jul 23, 2008
    Messages:
    4,360
    Likes Received:
    0
    set_ini is a directive used when you are using php to reach out into the web and grab content.

    User Agent is something the visitors browser sends to the server so there is no way, at least that I know of, of sending visitors to a target page with a bogus User Agent.

    I'm confused on what you're trying to accomplish, though. Why would you want to force all of your users to like as if they're using Firefox?
     
  19. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    http://www.justin-cook.com/wp/2007/01/29/how-to-set-the-curl-user-agent-string-with-php/

    this is what i want to do... but im not good with computer.. dunno how i got here
     
  20. hank85

    hank85 sudo shred /dev/sda -f -v -z --iterations=6

    Joined:
    Jul 23, 2008
    Messages:
    4,360
    Likes Received:
    0
    So you want to scrape web pages using curl?

    Setting headers for curl only affect the curl session you're about to initialize. And curl is used to go out and grab webpages.
     
  21. hank85

    hank85 sudo shred /dev/sda -f -v -z --iterations=6

    Joined:
    Jul 23, 2008
    Messages:
    4,360
    Likes Received:
    0
    Same thing, goes out, grabs content and then displays it to the user.
     
  22. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    where did you find this? i must be blind
     
  23. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    fuuuuu... yes this does exactly what i want :bowdown: :bowdown: :bowdown: :bowdown: :bowdown: :bowdown:
     
  24. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    this is so beyond awesome.. thanks guys.. lol
     
  25. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    9
    Location:
    Los Angeles
    This thread has good information to be referenced, so it will be undeleted. However, it will remain locked to prevent further commentary as the TS requested.
     
Thread Status:
Not open for further replies.

Share This Page