对本地的静态html文件发送http请求

需要对本地的html文件,或者说静态网页发送请求,只有前端页面,没有后端。前端的文件基本都有。

文件链接:D:/mystudysoft/weixinkaifa/WeChat%20Files/wxid_inmlsqlnnpqs22/FileStorage/File/2023-09/%E5%BE%B7%E5%9B%BD%E4%BA%A4%E9%80%9A%E6%A0%87%E5%BF%97%E8%AF%86%E5%88%AB/dist/build/h5/static/js/pages-index-index.ac96133b.js

是一个js文件,html文件同理

方法一:

python 复制代码
import urllib.request
urL = 'file:///D:/mystudysoft/weixinkaifa/WeChat%20Files/wxid_inmlsqlnnpqs22/FileStorage/File/2023-09/%E5%BE%B7%E5%9B%BD%E4%BA%A4%E9%80%9A%E6%A0%87%E5%BF%97%E8%AF%86%E5%88%AB/dist/build/h5/static/js/pages-index-index.ac96133b.js '
res=urllib.request.urlopen(urL)
html=res.read()
print(html)

方法二:

python 复制代码
import requests
from requests_file import FileAdapter
url = "file:///D:/mystudysoft/weixinkaifa/WeChat%20Files/wxid_inmlsqlnnpqs22/FileStorage/File/2023-09/%E5%BE%B7%E5%9B%BD%E4%BA%A4%E9%80%9A%E6%A0%87%E5%BF%97%E8%AF%86%E5%88%AB/dist/build/h5/static/js/pages-index-index.ac96133b.js"
s=requests.Session()
s.mount( 'file://',FileAdapter()) #调用函数

a=s.get(url)
print(a.text)
相关推荐
哀木4 分钟前
诶,这么好用的 mock 你怎么不早说
前端
Lear19 分钟前
UniApp PDF文件下载与预览功能完整实现指南
前端
Heo22 分钟前
关于XSS和CSRF,面试官更喜欢这样的回答!
前端·javascript·面试
7***A44344 分钟前
Vue自然语言处理应用
前端·vue.js·自然语言处理
高阳言编程1 小时前
vue2 + node + express + MySQL 5.7 的购物系统
前端
y***54881 小时前
React依赖
前端·react.js·前端框架
2***B4491 小时前
React测试
前端·react.js·前端框架
5***o5001 小时前
React自动化测试
前端·react.js·前端框架
T***u3331 小时前
React部署
前端·react.js·前端框架
6***94151 小时前
报错The default superclass, “jakarta.servlet.http.HttpServlet“(已经配置好tomcat)
http·servlet·tomcat