webcrawler link extraction problem
<p>im writing a simple webcrawler. the problem is, with the link extraction.</p>

<p>i uses the cpp-netlib with boost. here a few lines of my CLink Class.</p>

<pre><code>    CLink::CLink(const CLink&amp; father, const std::string&amp; relUrl )
    {
     uri = relUrl;
     boost::network::uri::uri instance(relUrl);
     boost::network::uri::uri instanceFather(father.uri);

     if ( (valid = boost::network::uri::is_valid(instance)) == 1)
      {
       scheme    = boost::network::uri::scheme(instance);
       user_info = boost::network::uri::user_info(instance);
       host      = boost::network::uri::host(instance);
       port      = boost::network::uri::port(instance);
       path      = boost::network::uri::path(instance);
       query     = boost::network::uri::query(instance);
       fragment  = boost::network::uri::fragment(instance);

       uri  = scheme;
       uri += "://";
       uri += host;
       uri += path;

      }
     else
      {
       if ( (valid = boost::network::uri::is_valid(instanceFather)) == 1)
        {

         scheme    = boost::network::uri::scheme(instanceFather);
         user_info = boost::network::uri::user_info(instanceFather);
         host      = boost::network::uri::host(instanceFather);
         port      = boost::network::uri::port(instanceFather);
         path      = boost::network::uri::path(instance);
         query     = boost::network::uri::query(instance);
         fragment  = boost::network::uri::fragment(instance);

         uri  = scheme;
         uri += "://";
         uri += host;
         uri += path;

        }
      }
    };

    CLink::CLink( const std::string&amp; _url )
    {

     uri = _url; 
     boost::network::uri::uri instance(_url);
      if ( (valid = boost::network::uri::is_valid(instance) ) == 1)
       {
       scheme    = boost::network::uri::scheme(instance);
       user_info = boost::network::uri::user_info(instance);
       host      = boost::network::uri::host(instance);
       port      = boost::network::uri::port(instance);
       path      = boost::network::uri::path(instance);
       query     = boost::network::uri::query(instance);
       fragment  = boost::network::uri::fragment(instance);


       uri  = scheme;
       uri += "://";
       uri += host;
       uri += path;

         }
        else
      std::cout &lt;&lt; "err " &lt;&lt; std::endl;
    };
</code></pre>

<p>the links from the webpage i took with the htmlcxx lib. i took the  HTML::Node and normalize them wih the boost filesystem.</p>

<pre><code> if ( url.find("http://") == std::string::npos)
  {
   std::string path = link.get_path() + url;   
   url =  link.get_host() + path;

   boost::filesystem::path result;
   boost::filesystem::path p(url);
   for(boost::filesystem::path::iterator it=p.begin(); it!=p.end(); ++it)
    {
     if(*it == "..")
      {
       if(boost::filesystem::is_symlink(result) )
    result /= *it;
       else if(result.filename() == "..")
    result /= *it;
       else
    result = result.parent_path();
      }
     else if(*it == ".")
      {
       // Ignore
      }
     else
      {
       // Just cat other path entries
       result /= *it;
      }
    }

   url = "http://" + result.string();
  }

 return ret;
</code></pre>

<p>Now the problem is.</p>

<p>i try to fetch <code>http://www.wikipedia.de/</code> and i get the urls like</p>

<p>properties
<a href="http://wikimedia.de/wiki/Vereinszeitung" rel="nofollow">http://wikimedia.de/wiki/Vereinszeitung</a>
  ... ...</p>

<p>and on the site <code>http://wikimedia.de/wiki/Vereinszeitung</code> there is a link like <code>/wiki/vereinsatzung</code></p>

<p>so often i get links like</p>

<pre><code>http://wikimedia.de/wiki/Vereinszeitung/wiki/Freies_Wissen
</code></pre>

<p>does someone have a idee?</p>
