对本地的静态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)
相关推荐
FluxArt1 分钟前
GPT Image 2.5 中文提示词教程:Flux Art 可复用模板
前端·gpt·算法
搬砖的小码农_Sky1 小时前
AI Agent:Windows上Node.js安装后 npm -v报错
前端·npm·node.js·人机交互
计算机魔术师1 小时前
半年翻倍!OpenAI再融300亿,估值冲到1.4万亿
前端
研☆香2 小时前
jQuery + Swiper.js 实现动态渲染轮播图
前端·javascript·jquery
子兮曰2 小时前
Node.js 50个优势场景盘点:一个人单干,为啥我多数时候只用它
前端·后端
IT_陈寒2 小时前
我花3小时debug,就因为JavaScript这个隐式转换坑
前端·人工智能·后端
excel3 小时前
Nuxt 中 useSeoMeta 与 useHead 的区别
前端
竹林8183 小时前
OmniGame 技术白皮书:从零依赖到 WebRTC P2P,重新定义网页小游戏的工程上限
前端·浏览器
ss2733 小时前
AI全栈实战 | 2.1-02 CSS 布局:垂直居中为什么是经典面试题?所有布局在解决什么矛盾
前端·css
律宏阔3 小时前
Flutter Riverpod 3:统一打印 Provider 错误与自动重试日志
前端·flutter