代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
from re import search
import web
import getData
### Url mappings
urls = ("/", "Index",
"/search", "Search",
'/(js|css|img)/(.*)','static' )
### Templates
render = web.template.render("templates", base="base")
class static:
def GET(self, media, file):
try:
f = open(media+'/'+file, 'rb')
return f.read()
except:
return ''
class Index:
form = web.form.Form(
web.form.Textarea(
"content", web.form.notnull, rows=30, cols=80, description='', placeholder="请输入url列表,用换行分隔"
),
web.form.Button("查询")
# ,
# validators = [web.form.Validator("urls不能为空.", lambda i: i.content == "")]
)
def GET(self):
form=self.form
return render.index(form)
def POST(self):
# if form.d.content=="":
# raise web.seeother("/tip")
form = self.form()
if not form.validates():
return render.new(form)
# print(form.d.title)
web.setcookie('urls', form.d.content)
raise web.seeother("/search")
class Search:
def GET(self):
urls=web.cookies().get('urls')
# urlArr=urls.split(",")
urlArr=urls.split("\r\n")
print(urls)
# print(urlArr)
posts=[]
for url in urlArr:
# print(getData.getData(url))
result=getData.getData(url)
item={'url':url,'title':result[3],'answerCount':result[0],'numberBoard_itemValue1':result[1],'numberBoard_itemValue2':result[2]}
print(item)
posts.append(item)
print(posts)
return render.result(posts)
app = web.application(urls, globals())
if __name__ == "__main__":
app.run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。