我这边试过好几种获取本地HTML内容的方法
内容上面如图所示
试过好几种获取网页内容方法
1、
r = requests.get('file:///D:/工作内容/工作内容/单病种质控/病种上报页/病种上报页/DVT%20围手术期深静脉血栓.html')
返回结果为:
InvalidSchema: No connection adapters were found for 'file:///D:/工作内容/工作内容/单病种质控/病种上报页/病种上报页/DVT%20围手术期深静脉血栓.html'
2、
soup=BeautifulSoup(open('file:///D:/工作内容/工作内容/单病种质控/病种上报页/病种上报页/DVT%20围手术期深静脉血栓.html',encoding='utf-8'),features='html.parser') 返回的结果为: OSError: [Errno 22] Invalid argument: 'file:///D:/工作内容/工作内容/单病种质控/病种上报页/病种上报页/DVT%20围手术期深静脉血栓.html'
3、
f = urllib.request.urlopen(url)
content = f.read().decode('utf-8')
这样就OK了,这是为啥?