This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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: 5130
135
  • 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: 5130
135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reposting your entire earlier post does not help.

Did you read my response?
 
Do not threaten THIS beaver! Not even with this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!