faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 18 people (50%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How can I set the User-Agent string for the web robot I'm writing?

Aug 15th, 1999 08:55
Nathan Wallace, se@lakenet.no


If you open a socket to retrive the pages, you just output:

    "User-Agent: whatever\n"

as one of the request headers.

I would use something like

    "User-Agent: bot_name/bot_version (bot_purpose; your@email)\n"

(and try to make the robot honor "robots.txt" and other nice things ;)

if you use fopen(" http://... the User-Agent is set somewhere near line
588 in fopen-wrappers.c...