• 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
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

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: 5395
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • 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: 5395
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reposting your entire earlier post does not help.

Did you read my response?
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!