代码
hostDir = 'https://www.example.com/a/b/'
path = '../../script.js'
x = hostDir + path
import requests
print(requests.get(x).content.decode('utf-8'))
当我运行上面的代码时,它给出以下错误:
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>
You don't have permission to access "http://www.xyz.com/a/b/../../script.js" on this server.<P>
Reference #18.3da21ab8.1546852663.7da6a685
</BODY>
</HTML>
我可以看到此问题是由于路径'../../'和'/ a / b /'引起的,但是请求模块无法将其转换为'https://www.example.com/scripts.js'
同时考虑“ ../../”和“ / a / b /”的次数。
请帮助我解决该问题,以便将其转换为“ https://www.example.com/scripts.js”