Reputation: 5445
I had a similar code as in this question. Extending the code, in accepted answer, worked for me too.
Before this time, I used this type of codes and never meet any exception.
Now, my questions are:
Is it necessary to use in every program?
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
is generated? (I want to know the exact formatting).Note that:
The program where I fixed it, I use it daily, but it never had any issue before.
Upvotes: 1
Views: 1853
Reputation: 12100
Many web administrators want to prevent bots from accessing their sites because what they do is scrape data at regular intervals but the owner can't earn any ad revenue from these hits. So no obvious benefits but they keep using resources. For this reason they block anything that doesn't look like a browser used by a human. As you have seen, it is completely trivial to make your program pretend to be another. So this technique is not effective against anyone who knows what they are doing. In general though, it is considered polite to not pretend something you're not (internet etiquette).
User agent strings can technically be anything you want, but most applications follow a common pattern such as $product/$version
. You can see some examples here.
For more information, check out the wikipedia article on the matter.
So quick summary:
JavaLib/1.1
), but you had to set your own for the reasons stated above.Upvotes: 4