首页 > 解决方案 > 我如何在 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>

标签: django

解决方案


你不能这样做是因为其他网站发送的CORSX-Frame headers一种方法是在服务器端使用请求库等模块,并在处理后将其响应呈现给您的站点。

提示:根据我的经验,如果您的域使用 HTTP 而不是 HTTPS,您可以在 iframe 中显示一些网站。


推荐阅读