在这种情况下, urlparse.urljoin 可以为您 提供 帮助。您应该像这样修改您的代码-
import bs4 as bs4import urllib.requestfrom urlparse import urljoinweb_url = 'https:www.example-page-xl.com'sauce = urllib.request.urlopen(web_url).read()soup = bs.BeautifulSoup(sauce,'lxml')section = soup.sectionfor url in section.find_all('a'): print urljoin(web_url,url.get('href'))在这里 urljoin 管理绝对路径和相对路径。



