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 12 of 12

Thread: How can I import data from a website to my program, or file

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I import data from a website to my program, or file

    Hi all,

    I want to import data from a web site (this is refresh every day), but I need only part of it, then read the necessary data from there. I tried to block it (array), but it did not work, and I've been looking for a lot of solutions, but I did not find it really good. How can I solve this?

    Thanks so much if anyone solves my problem.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How can I import data from a website to my program, or file

    What kind of server does the website have and what protocol does it use? Many use the HTTP protocol.
    To read data from the site, send the server an HTTP Get command, read its response, parse it and save the part that you want.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I import data from a website to my program, or file

    I don't know that information, sorry. Can you check? I am a beginner. --> ESPN: The Worldwide Leader in Sports

    How can I save part that I want? Which command? Please a bit more help, and thereafter I can search exampels. Many thanks!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How can I import data from a website to my program, or file

    I am a beginner
    This is a big project for a beginner and will require you to do lots of research.

    Do you know what the HTTP protocol is? Do a search and some reading to find out how it works.
    Java has several classes that you can use to use the HTTP protocol to read files from a server:
    For example: HttpURLConnection

    There are also some classes from the Apache project that would be useful, but I am not familiar with them.

    How can I save part that I want?
    I assume that the server returns an HTML page. Again you need to do some research about HTML.
    When reading the data returned by the server you will need to parse the part you want.
    Again I think the Apache project might have useful classes for that.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I import data from a website to my program, or file

    I have a simple code. It can download web pages into texts. Is it not a solution if I download it and read it out there? What do you think?

    In fact I just do not know which command to use in order to read the relevant part of the html code.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How can I import data from a website to my program, or file

    If the data is read from the server into a String, then there are methods in the String class to extract the parts that you want.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I import data from a website to my program, or file

    for example the HTMLEditorKit.Parser?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How can I import data from a website to my program, or file

    Sorry, I haven't used that class and don't know what it does.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I import data from a website to my program, or file

    np, Thank you for your help!

  10. #10
    Junior Member
    Join Date
    Dec 2018
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I import data from a website to my program, or file

    It is working?
    [Signature]studentloanresolved.com[/URL]

  11. #11

    Default Re: How can I import data from a website to my program, or file

    Thanks, it is helpful.

  12. #12
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    88
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How can I import data from a website to my program, or file

    Hi sir. I couldn't help noticing that you are from a sports network. And you are trying to import data from a website. Did you build this network yourself or another person to do it for you? Using some other program, I'm assuming. It could be any one of the browsers or programming language. Unix being a popular program also working with Java. Also popular is Fortran. How'd you start off your project? From one of the Java programs or JRE. Then trying this out. The file or program.
    Last edited by Helium c2; November 14th, 2023 at 03:27 AM. Reason: wording

Similar Threads

  1. Replies: 0
    Last Post: October 4th, 2017, 12:24 PM
  2. Import data from Excel to Access
    By solnaif in forum Member Introductions
    Replies: 1
    Last Post: July 14th, 2013, 07:16 PM
  3. how can I get my program to enter data on a website?
    By leonne in forum Java Theory & Questions
    Replies: 4
    Last Post: April 21st, 2013, 04:10 PM
  4. Program that selectively outputs data from a text file.
    By MJjavapf in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: September 23rd, 2012, 04:26 PM
  5. Program that reads data from a text file...need help
    By cs91 in forum Java Theory & Questions
    Replies: 4
    Last Post: October 3rd, 2010, 07:57 AM

Tags for this Thread