django - 我如何在 django 模板中显示另一个网站数据
问题描述
**urls.py**
urlpatterns = [
path('',views.index,name='index'),
]
**views.py**
def index(request):
return render(request,"index.html")
template.html 我的模板有 1) 输入框 2) 搜索按钮 3) 引导卡 当我输入任何 url 并点击搜索按钮时,网站数据应该出现在卡中
<input type="text" value="">
<button type="button">Search</button>
<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Search results will appear here</h5>
</div>
</div>
</div>
</div>
解决方案
你不能这样做是因为其他网站发送的CORS
。X-Frame headers
一种方法是在服务器端使用请求库等模块,并在处理后将其响应呈现给您的站点。
提示:根据我的经验,如果您的域使用 HTTP 而不是 HTTPS,您可以在 iframe 中显示一些网站。
推荐阅读
- python - cant change a symbol in every row from indexes list in Data Frame
- angular10 - 调试 Angular 10 项目时,我在 chrome windows 中没有 webpack 文件夹
- netlogo - NetLogo 中方向的平均值和标准差(以度为单位)
- python - 在python中解析excel并重建逻辑
- excel - 通过函数调用的变量返回零
- c# - 如何提取字符串二,一个在括号之间,两个不在括号中?
- mysql - 如何使用带有 where 子句的返回数据库对象在 node.js 中映射?
- matrix - 如何手动将协方差矩阵转换为相关矩阵?
- swift - SSH 连接到 SwiftUI 中的服务器
- java - 从 jmh 基准打印附加输出