Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Website Source

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Website Source

    Hi,
    I want to get complete HTML source of a web page ( web page URL given below )
    http://shop.safeway.com/superstore/s...sp?page=signin

    but the problem I have is that when I get the web page through a java program, I do not get
    the complete HTML code that is displayed in the browser. I have tried to get the web page by

    three different ways
    1. Using HTTpClient class
    2. Using URL Connection
    3. Using HTML Parser

    but the result is same i.e. I do not get the complete HTML source of the page.

    Furthermore, when I try to view the page source in any browser, I get exactly the same HTML
    source that I get by the Java program. But when I select some part of the page ( like login
    part) then I can view the HTML that is not displayed by the Java program. I want to get that HTML in my program


    Any help would be highly appreciated

    Thanking you


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Website Source

    Sounds like you might need to process some Javascript as well then. Maybe you could look into Rhino for this, not exactly sure how all that works though as I've just done what you've tried and just get the HTML data.

    // Json

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Website Source

    Hello expertOpinion. Welcome to the Java Programming Forums.

    I have deleted your duplicate thread, just to save on clutter.

    Take a look at this code snippet in our Java Tips & Tutorials forum:

    http://www.javaprogrammingforums.com...bsite-url.html

    Let us know if it works as expected...
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  4. #4
    Junior Member
    Join Date
    Jul 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Website Source

    Thanks for your response Json and JavaPF.
    Dear JavaPF, I have already tried that example that you sent to me. It does not work
    Dear Json, Can you please guide me the way I have to use Rhino. I tried to figure out but could not. I could not find any example related to my case on Rhino website.


    Thanking you

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Website Source

    I have attached two files.
    Source1 File contains page source that I get when I try to view the source in the browser and its the exactly same source that I get through my java program.

    Source2 File contains page source when I select/highlight the login form and then try to view the source in the browser, then I get that. I want to get that html source through my java program


    Thanks
    Attached Files Attached Files

  6. #6
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Website Source

    I've never used Rhino myself so I wouldn't really have a clue to be honest

    However looking at your 2 files there, if you have a look at Source1.txt you can see that its creating a page with frames, maybe you should have look at each frame separately.

    Topleft: /brands/genericredirecter.asp?Destination=/superstore/leftbar/topLeft.htm
    Basket: /superstore/single_addnew.asp
    Checkout: /superstore/topbar/defaulttopchkbar.asp?page=shop
    Topbar: /superstore/topbar/topbar.asp?pnav=shop
    Main: /brands/sslgenericredirecter.asp?destination=%2Fregister%2 Fsignin%2Easp%3Ffrom%3Dsignin%26microsite%3D
    Buttons: /superstore/topbar/bottomfooter.asp

    OR:

    Header: newheader.asp
    Main: /brands/sslgenericredirecter.asp?destination=%2Fregister%2 Fsignin%2Easp%3Ffrom%3Dsignin%26microsite%3D
    Buttons: /superstore/topbar/bottomfooter.asp


    // Json

  7. #7
    Junior Member
    Join Date
    Jul 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Re: Website Source

    Dear Json,
    Thank you very much. I tried to fetch the source from the frame directly and it worked.
    I got the source of page.

    I am extremely thankful to your

    Regards

  8. #8
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Website Source

    No worries, glad to help.

    // Json

  9. #9
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Website Source

    Hey expertOpinion. Just out of interest, what did not work about that link I sent you?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  10. #10
    Junior Member
    Join Date
    Jul 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Website Source

    Oh, I mean to say it did not help me in my problem. Otherwise there was no issue with the link and code posted there.

    Thanks

  11. #11
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Website Source

    Quote Originally Posted by expertOpinion View Post
    Oh, I mean to say it did not help me in my problem. Otherwise there was no issue with the link and code posted there.

    Thanks
    Ah OK I get you. I'm glad Json helped you solve this
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. How to Grab the HTML source code of a website URL index page?
    By JavaPF in forum Java Networking Tutorials
    Replies: 6
    Last Post: April 22nd, 2010, 02:46 PM
  2. [SOLVED] Books and sources for Java beginners
    By chronoz13 in forum Java Theory & Questions
    Replies: 1
    Last Post: April 15th, 2009, 08:36 AM
  3. Replies: 3
    Last Post: March 9th, 2009, 09:47 AM