Results 1 to 5 of 5
  1. #1
    Castle is offline Member
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Extracting

    I am trying to use regex to extract all the <a href links and print them, but I think it keeps reading the URL instead of the HTML, the code I have currently is:

    Any way I can make this work? I think I have the right concept, but implementing it seems tricky.
    Last edited by Castle; 11-27-2012 at 11:34 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Extracting <a href links from html code using regex

    Um, you need to actually connect to that URL, via a URLConnection.
    At the moment you are, as you suspect, simply matching against the String "http://www.google.co.uk".
    Please do not ask for code as refusal often offends.

  3. #3
    Castle is offline Member
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Extracting <a href links from html code using regex

    My parameter needs to stay as a String and I can't cast from a string to an URL, how do I connect to the URL with the string?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Extracting <a href links from html code using regex

    You need to get one of these, from one of these.
    Then read from this to get the HTML.
    Please do not ask for code as refusal often offends.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Extracting <a href links from html code using regex

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. how to get links in html file
    By atia akram in forum New To Java
    Replies: 3
    Last Post: 11-04-2012, 05:26 PM
  2. help me..how to get links in html file
    By thangbomlennet in forum New To Java
    Replies: 13
    Last Post: 11-03-2012, 05:31 PM
  3. Replies: 5
    Last Post: 06-25-2011, 08:45 PM
  4. using href for JEditorpane reading html file
    By crozarius in forum Advanced Java
    Replies: 0
    Last Post: 04-13-2011, 07:08 PM
  5. How find Links in a HTML Page
    By binumathew in forum Networking
    Replies: 6
    Last Post: 08-03-2010, 06:49 PM

Tags for this Thread

Posting Permissions

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