Flask中图片的刷新

最近需要爬虫去抓取公众号的文章,需要获取公众号的唯一id,从某个网站抓取了一些,只是很少的一部分,最后还是得从搜狗去抓这个id,而公众号的文章通过客户端抓包去抓取,去抓搜狗会出现验证码,用flask搭建了一个服务,专门去做验证码的处理,由于缓存的问题,图片覆盖了,但是前端页面刷新还是以前的旧图。
index.html

<body>
 <div class="main">
 <img id='imgs' src="{{url_for('static',filename='images/capture.png',_t=val1)}}">
</body>

views.py

@app.route('/'):
@app.route('/index/')
def index()
    return render_template("index.html",val1=time.time())

需要_t参数,使每次请求的数据不一样,才能刷新图片

猜你喜欢

转载自blog.csdn.net/qq_23279427/article/details/72876109