BaseParser._make_absolute() produces inaccurate results if self.base_url contains a path
If self.base_url contains a path component, then BaseParser._make_absolute(link) will produce inaccurate results.
For example, if http://example.com/testdir/test.html contains a link to test2.html then .absolute_links and .next() will point to http://example.com/test2.html instead of /testdir/test2.html.
because of <base> tag?
No, I don't see any such tag on the page. I inspected the source code of _make_absolute(link) and I don't see any place where it merges the path of the base_url with the path of the relative link. I'll see if I can produce a concrete example.
>>> from requests_html import HTMLSession
>>> session = HTMLSession()
>>> s = session.get('https://docs.python.org/3/tutorial/index.html')
>>> s.html.base_url
'https://docs.python.org/3/tutorial'
>>> s.html.next()
'https://docs.python.org/appetite.html'
Expected value is https://docs.python.org/3/tutorial/appetite.html. s.html.absolute_links is also affected (output too large to share here). The problem is definitely in ._make_absolute(link).
I think I can submit a proposal PR for this, if you don't mind reviewing it. I'll whip something up.
@andrewsg thanks!