reading webpages

Discussion in 'OT Technology' started by Leb_CRX, Jul 8, 2003.

  1. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    I am just wondering here..

    I want to be able to write code that basically reads a webpage to allow me to manipulates links...and I want to do this in java...

    I know this can be done in PERL fairly easy, but I am wondering how I can do this in java, since that's my #1 language right now...

    I am positive this can be done, just unsure about how to start writing this...basically say for example I have a webpage that has 10 links to .jpg pictures...I want my code to be able to save those pics in files...

    like I wish I could put a URL, save it locally, open it as a txt file, search for the tag 'a href = '''555555555'''' read the 555555, be able to open that and go from there.....

    I hope that is making sence, this is nothing but a 'fun to have' code..you know just to challenge myself and learn something new

    Any ideas??

    thanks
    |eb_CRX
     
  2. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    you can open a url connection using URL class, not sure how you can save jpg files to your hdd using java program but what you want to do can be done in java for sure
     
  3. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Open a URL connection and read an input stream. Maybe a file input stream actually. You could write a file of the html locally and at the same time scan for any img tags. When you reach them, parse out the URL to the image and save it to a seperate file.

    If you really wanted some fun, follow any a href tags like you suggested, but make a new thread for each. The way I'm thinking about it would require some syncronization, but I'll leave that for you to figure out. ;)
     
  4. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
  5. Fantik

    Fantik Guest

    read API on file objects and URL objects... it aint that hard.
     

Share This Page