Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Imitating a specific browser

Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

If I want to connect to a particular website, I'll often use the URL class and it's openStream() method. However, on occasion, I can't connect to the web server this way as they probably have in place some sort of device to prevent the scanning from unknown sources. I can navigate fine to the same website using the exact same URL in my IE browser no problem. So I'm thinking that a browser must be identifying itself to the server somehow in the HTTPRequest object sent to the server. That being the case, how does one imitate the source request as having come from IE or some other browser? Is there a property I can set on some other class before I call the URL.openStream() method?

Posts: 43011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the HtmlUnit library - it can imitate various browsers, and does a very good job of programmatic web access.
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!