对本地的静态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)
相关推荐
excel1 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端
Aphasia3111 小时前
https连接传输流程
前端·面试
徐小夕1 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
threelab1 小时前
Three.js 物理模拟着色器 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器
kyriewen1 小时前
CSS Container Queries:彻底告别 @media 写到手软,附 5 个真实布局案例
前端·css·面试
小小小小宇3 小时前
OpenMemory MCP
前端
和平宇宙3 小时前
AI笔记005. hermes-DeepSeek V4 Pro, 128K上下文引发的探索
前端·人工智能·笔记
IT_陈寒4 小时前
Redis持久化这个坑,我爬了一整天才出来
前端·人工智能·后端
naildingding4 小时前
3-ts接口 Interface
前端·typescript
小小前端仔LC4 小时前
Node.js + LangChain + React:搭建个人知识库(六)- “吃什么”项目实战:从700+菜谱入库到Taro H5端JSON渲染
前端·后端