Skip to content

Commit

Permalink
修改html 搜索结果样式
Browse files Browse the repository at this point in the history
  • Loading branch information
dirpc-sdk-builder committed Jan 3, 2021
1 parent 829d6b9 commit 98ff3c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
8 changes: 4 additions & 4 deletions parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ def _find_title_from_body(soup, default):
return None

def _get_title(soup, default):
r = _find_title_from_body(soup, default)
if r:
return r
r = _find_title_from_tag(soup, ["title"], default)
if r:
return r
r = _find_title_from_tag(soup, ["h3", "h4", "h1", "h2", "h5"], default)
if r:
return r
r = _find_title_from_tag(soup, ["p"], default)
r = _find_title_from_body(soup, default)
if r:
return r
"""
r = _find_title_from_tag(soup, ["p"], default)
if r:
return r
r = _find_title_from_tag(soup, ["span"], default)
if r:
return r
Expand Down
2 changes: 0 additions & 2 deletions search_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import logging
import traceback


logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)


reload(sys)
sys.setdefaultencoding('utf-8')

Expand Down
26 changes: 21 additions & 5 deletions wiz_search_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from string import Template
import markdown


reload(sys)
sys.setdefaultencoding('utf-8')

Expand All @@ -38,7 +39,10 @@
a{margin: 17px}
a{margin-top: 25px}
a{font-style:bold;}
a{font-family: Arial, Helvetica, sans-serif }
a{
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
a{color:#0066CC}
a:link { text-decoration: none;}
a:active { text-decoration:blink}
Expand All @@ -50,19 +54,28 @@
p{margin: 6px}
p{margin-left: 16px}
p{font-style:bold;}
p{ text-decoration: none;color: #404040 }
p{
text-decoration: none;
color: #111729c4;
}
div {
background-color: #FFFFFF ;
width: 800px;
border: 1.4px solid #F0F0F0;
padding: 2px;
padding-top:8px;
padding-top:10px;
margin: 4px;
margin-top: 7px;
margin-left: 44px;
}
div:hover {
border: 1.4px solid #D8D8D8;
background-color: #dee6f166;
}
.topstatus {
background-color: #e2f1c95c;
}
.searchText {
Expand Down Expand Up @@ -131,7 +144,7 @@ def GET(self, name):

class somehtml:
def md2html(self, mdstr):
exts = ['markdown.extensions.extra', 'markdown.extensions.codehilite','markdown.extensions.tables','markdown.extensions.toc', 'markdown.extensions.fenced_code', 'markdown.extensions.codehilite', 'markdown.extensions.nl2br']
exts = ['markdown.extensions.extra', 'markdown.extensions.codehilite','markdown.extensions.tables','markdown.extensions.toc', 'markdown.extensions.fenced_code', 'markdown.extensions.nl2br']
html = '''
<html lang="zh-cn">
<head>
Expand All @@ -143,7 +156,10 @@ def md2html(self, mdstr):
</body>
</html>
'''


ret = markdown.markdown(mdstr, extensions = exts)
print ret
return html % ret

def GET(self, name):
Expand Down Expand Up @@ -208,7 +224,7 @@ def return_html(self, ori_query, result):
else:
timeused = time.time() - web.search_start_time
timeused = float('%0.4f'%timeused)
SEARCH_STATUS="<div><p>共找到 %s 条结果, 耗时 %s 秒</p></div>"%(result_count, timeused)
SEARCH_STATUS='''<div class="topstatus"><p>共找到 %s 条结果, 耗时 %s 秒</p></div>''' % (result_count, timeused)

r = templ.substitute(SEARCH_STATUS=SEARCH_STATUS, SEARCHRESULT=result_html, INPUTVALUE='''value="%s" '''%ori_query.encode('utf-8'))
return r
Expand Down

0 comments on commit 98ff3c6

Please sign in to comment.