How to find all (complete) sublinks from a web page using lxml in Python
<p>The following code takes a URL and returns a list of links to pages that are contained on the original url page.</p>

<pre><code>import urllib
import lxml.html

def getSubLinks(url):
sublinks = []
connection = urllib.urlopen(url)
dom = lxml.html.fromstring(connection.read())
for link in dom.xpath('//a/@href'):
    sublinks.append(link)
return sublinks
</code></pre>

<p>This seems to work, except for, for pages on the same domain it strips the domain from the URL and this is not what I want. I want to get the full unaltered link back. For example, using this on the webpage:</p>

<p>"<a href="http://www.nufc.com" rel="nofollow">http://www.nufc.com</a>"</p>

<p>returns the list (and much more):</p>

<pre><code>['http://www.altoonativetravel.com/', 'index.htm',    '2015-16html/fixtures.html', .....
</code></pre>

<p>However as you can see the preceding "<a href="http://www.nufc.com" rel="nofollow">http://www.nufc.com</a>" has been stripped from '2015-16html/fixtures.html' and others whereas I do not want this to happen, I want '<a href="http://www.nufc.com/2015-16html/fixtures.html" rel="nofollow">http://www.nufc.com/2015-16html/fixtures.html</a>'. How can I fix this?</p>