Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
解决搜索无小说网站显示undefined的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ling7334 committed Jun 18, 2016
1 parent cd15700 commit 8e24f41
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 5 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ def config():
html = open('./webui/config.html',encoding='utf8').read()
return html

@app.route('/favicon.ico')
def send_ico():
return send_from_directory('./webui/', 'favicon.ico')

@app.route('/js/<path:path>')
def send_js(path):
return send_from_directory('./webui/js', path)
Expand All @@ -353,4 +357,4 @@ def send_img(path):
return send_from_directory('./webui/img', path)

if __name__ == '__main__':
app.run(host="0.0.0.0")
app.run(host='0.0.0.0', debug=True)
5 changes: 4 additions & 1 deletion usrlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def Search_By_ID(novelname,id):
return -1 #网站无法连接
soup = BeautifulSoup(data,"html.parser") #构建BS数据
string = 'soup.' + opts["novel_link"]
url = eval(string) #获取小说页面链接
try:
url = eval(string) #获取小说页面链接
except:
return -1
if not url.startswith('http'):
url = opts["url"] + url #构建小说页面链接
# try:
Expand Down
Binary file added webui/favicon.ico
Binary file not shown.
16 changes: 12 additions & 4 deletions webui/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ var query_status = 1;
function getnovel(i,id){
if (id[i] == null){return false}
var html="";
if (query_status==i){
if (query_status==1){
$.ajax({
type:'post',
dataType:'json',
url:'/search',
data: { "id": idlist.id[i], "novelname": $("#search-novel").val() },
beforeSend:function(){$(".progress").show();query_status =i},
beforeSend:function(){$(".progress").show();query_status =0},
complete:function(data){
obj = JSON.parse(data.responseText);
if (obj=='-1'){
$(".progress").hide();
query_status = 1;
i=i+1;
getnovel(i,id);
return false;
}
html+='<a class="list-group-item row" style="cursor: pointer;" onclick="Retrieve(\''+ obj.id+'\',\''+obj.title +'\',0)">';
html+='<h4 class="list-group-item-heading">'+ obj.website + ' - ' + obj.title +'</h4>';
html+='<span class="list-group-item-text col-md-4">最新章节:'+ obj.latest +'</span>';
Expand All @@ -22,8 +29,8 @@ function getnovel(i,id){
html+='</a>'
$(".list-group").append($(html));
$(".progress").hide();
query_status = i+1;
i=i+1;
query_status = 1;
i=i+1
getnovel(i,id);
},
error:function(XMLResponse){alert(XMLResponse.responseText);}
Expand All @@ -43,6 +50,7 @@ function search(){
idlist = JSON.parse(id.responseText);
$(".list-group").remove();
$(".container").append($(listgroup));
query_status = 1;
getnovel(0,idlist.id);
//query_status =1;
},
Expand Down

0 comments on commit 8e24f41

Please sign in to comment.