Results 1 to 7 of 7

Thread: java

  1. #1
    Kruptein is offline Member
    Join Date
    Aug 2009
    Posts
    32
    Rep Power
    0

    Thumbs down java

    Hey,

    Is it possible (it always is, the question is how :)
    to get a file from internet, read the string, cut it in pieces, open your browser with a link wherein the cutted string is

    All those in 1 second?

    I don't need a whole script (although it would always be nice :)
    but just some function-names that I will need to do this.

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    sorry, but you lost me when you said "cut it in pieces" and everything beyond it.

    from what i can tell, you want to read html from an url, parse html, and execute an external program with parameters.

    using those terms on search engines, you should be able to find a lot of useful info on the internet, if not at least have good starting points.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    You can use a URL object and a stream reader to read a web page.
    You can use Java's REGEX package to scrape information from said page.
    You can then use Java's Process object to start a native app with parameters.

  4. #4
    Kruptein is offline Member
    Join Date
    Aug 2009
    Posts
    32
    Rep Power
    0

    Default

    Thanks quad64bit, I will try it out :),

    I will it explain with an example for you emceenugget :)
    if you open:
    example.be/example.php
    you see:
    text: "This is the text"

    you need to send:
    This is the text
    to
    example.be/validate.php?text=This is the text

    All in 1 second, got it?

    Kruptein

  5. #5
    Kruptein is offline Member
    Join Date
    Aug 2009
    Posts
    32
    Rep Power
    0

    Default

    Thanks quad64bit, I will try it out :),

    I will it explain with an example for youemceenugget :)
    if you open:
    example.be/example.php
    you see:
    text: "This is the text"

    you need to send:
    This is the text
    to
    example.be/validate.php?text=This is the text

    All in 1 second, got it?

    I know have this:
    Java Code:
    try {
               // Create a URL for the desired page
                URL url = new URL("site"); 
    //I couldn't write a url because I haven't 20 posts yet
    
                // Read all the text returned by the server
                BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                String str;
                while ((str = in.readLine()) != null) {
                    System.out.println(str);
                }
                in.close();
            } catch (MalformedURLException e) {
            } catch (IOException e) {
            }
    this gave me an output with forms and logins, although there is only one thing written on that page: the "letters" are: 'example'

    What have I done wrong?

    Kruptein

  6. #6
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    that page check login
    you need to login the website before access

  7. #7
    Kruptein is offline Member
    Join Date
    Aug 2009
    Posts
    32
    Rep Power
    0

    Default

    How do I
    a) avoid it
    b) solve it (I'm a member of the site so I can login)
    With solv'it I mean:
    a) Login via java and then do the action I want to do in first place
    b) Only do the action I want to do, but tell a way that I only have to login in my browser or something like that

    thanks for your fast reply!

Posting Permissions

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