Results 1 to 7 of 7
  1. #1
    ahmakki is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default download website source code problem

    hey,
    i am trying to download source code of a webpage but for some webpages i have this error :

    Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: xxxxxx at sun.net.http://www.protocol.http.HttpURLConn...tion.java:1441)
    at java.net.URL.openStream(URL.java:1010)
    at WebsiteReader.read(WebsiteReader.java:7)
    at WebsiteReader.main(WebsiteReader.java:13)

    and this is my code
    :
    import java.io.*;
    import java.net.URL;
    .
    .
    .

    public static BufferedReader read(String url) throws Exception{
    return new BufferedReader(
    new InputStreamReader(
    new URL(url).openStream()));}

    public static void main (String[] args) throws Exception{
    BufferedReader reader = read("http://www........");
    String line = reader.readLine();
    .
    .
    .

    any help please .

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    Have you tried to enter that URL into your browser?

    A 403 is a Forbidden error.

  3. #3
    ahmakki is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default source code

    yes i entered the url and it works fine and i was able to see the source code in the browser firefox , i was reading on the internet i think there is a proxy problem and i am not familiar with the proxies !!!

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    Do you know what traffic is going on when you make the request from your browser?
    I'd look at that if I were you.

  5. #5
    ahmakki is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default question

    i know this is maybe a stupid question but how can i do that and how can that help me ! thanks for your patience .

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    Sorry, should have thought of that!

    I use Firebug for Firefox, which has a Console window in which all the calls to the server, and the response, are logged. I suspect there's something similar for whatever browser you're using.

    This may not be your problem, but at least you'll be able to see if anything else is happening.

  7. #7
    ahmakki is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default

    i will check it out on firebug but in all the forms about this error they talk about proxy ! do u think it may be the problem that the url i am tryin to use is using a proxy

Similar Threads

  1. [Java] getting links from website source
    By pietertje in forum New To Java
    Replies: 6
    Last Post: 07-01-2010, 09:36 PM
  2. Replies: 0
    Last Post: 03-27-2010, 11:21 AM
  3. How to download data from a website.
    By bobrenjc93 in forum Java Applets
    Replies: 2
    Last Post: 05-15-2009, 07:08 AM
  4. Replies: 1
    Last Post: 11-28-2008, 06:27 PM
  5. How to download website (Get all link in website)
    By finalmem in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2008, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •