• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Server returned HTTP response code: 403 for URL:  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
During scrapping a secured SSL implemented webpage in Java i got this error:

java.io.IOException: Server returned HTTP response code: 403 for URL: https://mobilefone.pk/

Below is my Java Code for scrapping HTTPS url

URL url = new URL("https://mobilefone.pk/");
       InputStream is = url.openStream();
       int ptr = 0;
       StringBuffer buffer = new StringBuffer();
       while ((ptr = is.read()) != -1) {
           buffer.append((char) ptr);
       }
       String data = buffer.toString();
       System.out.println("Scrapped Data=" + data);


Please help me to scrapp secured HTTPS url in Java.
 
Saloon Keeper
Posts: 5288
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The site probably doesn't like being scraped (not scrapped), and checks if the access looks like it's coming from a browser. Make sure what you're trying to do is in accordance with the site rules. If it is, you could try sending some additional headers that a browser would normally send. The User-Agent header alone might be sufficient.
 
Muhammad Nawaz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Muhammad Nawaz wrote:During scrapping a secured SSL implemented webpage in Java i got this error:

java.io.IOException: Server returned HTTP response code: 403 for URL: https://mobilefone.pk/

Below is my Java Code for scrapping HTTPS url




Please help me to scrapp secured HTTPS url in Java.

 
Tim Moores
Saloon Keeper
Posts: 5288
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reposting your entire earlier post does not help.

Did you read my response?
 
Our first order of business must be this tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!