• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Server returned HTTP response code: 403 for URL:

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reposting your entire earlier post does not help.

Did you read my response?
 
reply
    Bookmark Topic Watch Topic
  • New Topic