A sad story about the unfamiliar Java that led to the making of wheels

Source: Internet
Author: User

A recent project is to implement a simple vertical search engine, in the crawler, to analyze all the URLs on the page. But some URLs take the form of a relative link address.

For example: http://blog.csdn.net/lizhihaoweiwei/article/details/17839481 This page has a link called 34342, then the real address of this link is:

http://blog.csdn.net/lizhihaoweiwei/article/details/34342. So I'm going to write a function to complete the conversion. Taking into account the following circumstances:

The same layer./

Root Tier/

May be the current layer may also be a stand-alone URL abc

Upper layer (previous layer above) Wait

Write a hard function to deal with these situations, to consider the fault tolerance of processing, writing a bit complicated. After the realization of a little complacent mood.

Finally accidentally found that the URL class has several construction methods, one of which is the URL (url,string), the first look at the construction method to feel a little strange, what is the initial parameter URL meaning. Again, this may be a reference to the URL, the latter may be relative to the link address. The final validation is true. It's not a good deal to waste a couple of hours in this place.

Summary: Write code to have jumped out of the mind, a glance at the small mountains of the feeling. Do not worry about solving problems, but to figure out how to solve them. For example, this is to deal with the URL-related, you should first see whether the URL provides this function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.