[java] Getting links from website source

Discussion in 'Programming' started by Pieman, Jun 29, 2010.

  1. #1
    So I'm writing this program in java which will connect to a website, get it's source and search it for links (<a href="link" target="_blank">)

    Now in php I would just do
    <?php
    preg_match_all("/<a href=\"(.*?)\" target=\"_blank\">/", $source, $matches);
    ?>
    PHP:
    Which would put all the links neatly in $matches[1] in array form. I have however no idea how to do this in java, I know I have to use java.util.regex.Matcher and java.util.regex.Pattern, but how to go from there has left me stumped.

    Could anyone help me out here?

    Thanks.
     
    Pieman, Jun 29, 2010 IP
  2. Blue Star Ent.

    Blue Star Ent. Well-Known Member

    Messages:
    1,989
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    160
    #2
    You may look at these, LINK and LINK
     
    Blue Star Ent., Jul 15, 2010 IP