Retrieve partial domain

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onequestion
    New Member
    • Dec 2007
    • 8

    Retrieve partial domain

    Hi..
    We are providing free access to certain web pages to our customers because some sponsers will pay for that. For the convenience of the sponsers,we have to produce per url accounting to them.
    for example:

    URL Total.no.of.byt es accessed
    http://yahoo.com 23456
    http://www.google.com 36786

    one sponser will pay for yahoo.com and another will pay for google.com

    so i'm getting the data from cache(access.lo g) and i am comparing it with free_webpage_li st file. now i have to compare URLs like com http://www.yahoo.com from access.log file of cache and http://www.mail.yahoo. co.in from free_webpage_li st file,so i'm trying to compare "yahoo" in both the URLs. After comparing i have to calculate the bytes used for those webpages.


    Code:
    private String getDomain(URL url)  
       { 
       	 String domain;  
      	 Pattern p = Pattern.compile("[.]");
        	 String s[]=p.split(url.getAuthority());
        	 if(s[(s.length-1)].length()==2) 
       		 domain = s[s.length-3];
        	 else    
    		 domain = s[s.length-2];
        	 return domain;     
    }


    to retrieve yahoo from both the files i'm using this code. but it works only for 3digit country specific domain(.com,.ed u,.net and so on) and 2+2 country specific domains(co.in,c o.uk,co.us). Not for TLDs like cc.tx.us
    any help will be greatly appreciated..
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    If you'd like, post the whole code, see what we can salvage...

    It sounds like you should be able to get if it works with 3 chars.

    In a bit!

    Comment

    Working...