473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.bytes 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.log) and i am comparing it with free_webpage_list 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_list file,so i'm trying to compare "yahoo" in both the URLs. After comparing i have to calculate the bytes used for those webpages.


Expand|Select|Wrap|Line Numbers
  1. private String getDomain(URL url)  
  2.    { 
  3.         String domain;  
  4.        Pattern p = Pattern.compile("[.]");
  5.          String s[]=p.split(url.getAuthority());
  6.          if(s[(s.length-1)].length()==2) 
  7.             domain = s[s.length-3];
  8.          else    
  9.          domain = s[s.length-2];
  10.          return domain;     
  11. }


to retrieve yahoo from both the files i'm using this code. but it works only for 3digit country specific domain(.com,.edu,.net and so on) and 2+2 country specific domains(co.in,co.uk,co.us). Not for TLDs like cc.tx.us
any help will be greatly appreciated..
Feb 12 '08 #1
1 1265
Dököll
2,364 Expert 2GB
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!
Dec 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Vanessa | last post by:
I have a question, is that any other way to retrieve data from another webpage besides using XML object? Because I am using XML object now but give me so much problems. If I used...
3
by: Bruno | last post by:
Hello Friends I have a big problem. I can't retrieve the domain name (example: contoso.com) using visual basic.net language. I'm very appreciate if anyone give me an example how can I solve...
1
by: Lyners | last post by:
What I need - To retrieve the server name that the ASP application is running on. Why - Our current intranet is on a network where we have users that are on a domain and some that are not. Using...
1
by: Ioannis Gyftos | last post by:
Hello, First the code :) /////////////////////////////////////////////////////////////////////////////////// // in another header file namespace LJC{
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.