对本地的静态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)
相关推荐
zwjapple13 分钟前
docker-compose一键部署全栈项目。springboot后端,react前端
前端·spring boot·docker
AA-代码批发V哥2 小时前
HTML之语义化标签与多媒体标签
html
像风一样自由20202 小时前
HTML与JavaScript:构建动态交互式Web页面的基石
前端·javascript·html
aiprtem3 小时前
基于Flutter的web登录设计
前端·flutter
浪裡遊3 小时前
React Hooks全面解析:从基础到高级的实用指南
开发语言·前端·javascript·react.js·node.js·ecmascript·php
why技术3 小时前
Stack Overflow,轰然倒下!
前端·人工智能·后端
GISer_Jing3 小时前
0704-0706上海,又聚上了
前端·新浪微博
止观止4 小时前
深入探索 pnpm:高效磁盘利用与灵活的包管理解决方案
前端·pnpm·前端工程化·包管理器
whale fall4 小时前
npm install安装的node_modules是什么
前端·npm·node.js
会飞的鱼先生4 小时前
Node.js-http模块
网络协议·http·node.js