Python requests and BeautifulSoup4 .get('href') returning absoulte address : I'm trying to scrape the contents of `<a>` tags from a web page. My code is:

    from bs4 import BeautifulSoup
    import requests
    import sys
    
    reload(sys)
    sys.setdefaultencoding('utf-8')
    
    url = 'https://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961'
    
    req = requests.get(url)
    soup = BeautifulSoup(req.text, 'html.parser')
   
    lessons = soup.find_all('li', class_='toc-level-1')
    lesson = lessons[0]
    print(lesson)

My page has an element:

    <li class="toc-level-1 t-toc-level-1 js-content-uri" data-content-uri="/api/v1/book/9780134985961/chapter/LPOC_00_00_00.html">
       <a href="/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html" class="t-chapter" tabindex="39">Introduction</a>
       <ol>
          <li class="toc-level-2 t-toc-level-2 js-content-uri" data-content-uri="/api/v1/book/9780134985961/chapter/LPOC_00_00_00.html"><a href="/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html" class="t-chapter" tabindex="41">Linux Performance Optimization: Introduction</a></li>
       </ol>
    </li>

However, when I use requests and the bs4 modules to scrape the data, with the above code, the output I get is:

    <li class="toc-level-1 t-toc-level-1">
        <a class="t-chapter js-chapter" href="https://www.safaribooksonline.comhttps://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html">Introduction</a>
        <ol>
            <li class="toc-level-2 t-toc-level-2">
                <a class="t-chapter js-chapter" href="https://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html">Linux Performance Optimization: Introduction</a>
            </li>
        </ol>
    </li>

Notice the href values of the `<a>` tags? They're supposed to be relative URLs like: `/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html` but I get absolute ones - and that too wrong sometimes: `https://www.safaribooksonline.comhttps://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html`.

I have no clue how the domain name gets prefixed to the link url, since only the href value is given in the original HTML, unless requests or bs4 is doing this. All my previous scripts that used this same method are also producing a similar error. Did something change on the side of the modules, or am I doing something wrong?