I\'m trying to get all the href\'s from a HTML code and store it in a list for future processing such as this:
Example URL: www.example-page-xl.com
In this case urlparse.urljoin helps you. You should modify your code like this-
import bs4 as bs4
import urllib.request
from urlparse import urljoin
web_url = 'https:www.example-page-xl.com'
sauce = urllib.request.urlopen(web_url).read()
soup = bs.BeautifulSoup(sauce,'lxml')
section = soup.section
for url in section.find_all('a'):
print urljoin(web_url,url.get('href'))
here urljoin manage absolute and relative paths.