From fa56a2d9687fa6a7a48ca93d355ccbdc97faa885 Mon Sep 17 00:00:00 2001 From: lzjqsdd Date: Mon, 9 May 2016 21:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E9=97=BB=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ml/Search.py | 24 +++++++++- ml/Search.pyc | Bin 3042 -> 3705 bytes web/main.py | 22 +++++---- web/main.pyc | Bin 1814 -> 1848 bytes web/templates/footer.html | 0 web/templates/{header.html => index.html} | 4 +- web/templates/list.html | 0 web/templates/news.html | 53 +++++++++++++--------- web/templates/test.html | 10 ---- 9 files changed, 70 insertions(+), 43 deletions(-) delete mode 100644 web/templates/footer.html rename web/templates/{header.html => index.html} (91%) delete mode 100644 web/templates/list.html delete mode 100644 web/templates/test.html diff --git a/ml/Search.py b/ml/Search.py index 378e690..867640d 100644 --- a/ml/Search.py +++ b/ml/Search.py @@ -72,6 +72,7 @@ class Search: tm = time.localtime(int(data['time'])) data['time'] = time.strftime('%Y-%m-%d %H:%M:%S',tm) data['content'] = data['content'][0:Global.snippetsize] + data['id'] = rst newslist.append(data) return newslist @@ -80,8 +81,27 @@ class Search: pass #返回最新新闻 - def QueryByTime(self): - pass + def QueryByTime(self,searchPhrase): + newslist = self.QueryPhrase(searchPhrase,False) + return sorted(newslist,lambda x,y:cmp(y['time'],x['time'])) + + def QueryById(self,no): + no = int(no.decode('utf-8')) + default = dict() + default['title'] = "No Such News" + default['time']='' + default['content'] = "Oh No!" + default['url'] = "#" + if not no: + return default + cut = Cut() + line = cut.getRow(no,Global.cutnews_origin_dir,Global.filesize) + if line: + data = json.loads(line) + return data + else: + return default + #search = Search() #search.QueryPhrase(sys.argv[1]) diff --git a/ml/Search.pyc b/ml/Search.pyc index 933cfa13018c1037beee782915baf7cd9d799dda..e07162b41f730ac83f7af179af545511cb9c8542 100644 GIT binary patch delta 842 zcmYLH&1(};5TDu4yv?UdtkzP~RCF(jifF)~C3;W~vAz{s1P?KrQkT?dc7p~tM2H{= z+Lnh`Fa8PnBRu&x2wntFq9;+%nU_LI=J$Rx^XBvI*SX&duK6qP$#-XW-S2p7_h%y? zI`9hMz5p5c?zDz$7XFy-*bZjCL2ASG2Vc|&=ToHsX$itS)YBY9^Q=q|@TtHxG6a4> zy>MT;i2(qQ!s#DZA+D%xaTPuFS+vHhWRKYi*yh9BlWTOwRe}^CB1A|KCI*ZQpj@c| zA#!(Q34D%g>S$&bNk9^p2@)MjcaKsYKK27-iTsN`@-42~-g=@lQ5}Hi8i(qiIKGl0 zz20qYJq%k{?h%hkz~>Nonc);c;t<5We$okN9_~V(XSk&PimH0;6~}k^4m$u3&Zgxk zHt1>J6PfiJA@@par2mK}H(&xhc{rQggnDS{9oWPi&0Jy`%>=y!LcGdKK$CH(38@L= zh=M4a4UwbKg^39xGFs4o3rPkd!JLcQ{K5fe2x*(XN3Atun{be9oUX+=)_av;(B7;x zJI`WSob^uQ@>XM>>o&Q1OY#7Fc%{pmdd-7=SErM6WRr&&<{3yp9%kTu%Oec@f-=j% z1%1vcd0qNzdfZD~;$df_HRvXCk(~vGDlhzkAbMxe=?@#jo8dYs@d5#083lTKKL;(+ zj-i7^v<%-|5^IC9Q0Y!qWL4?iZYF-0A9w3vAk&~H|gHx18Y4UDf SJw}7cuXxQERVOR*MF0Rn`Y8th diff --git a/web/main.py b/web/main.py index 385da61..c209bba 100755 --- a/web/main.py +++ b/web/main.py @@ -16,21 +16,27 @@ class index: def __init__(self): self.se = Search() def GET(self): - searchword = web.input().searchword + data = web.input() + if data: + searchword = data.searchword + else: + searchword = '' newslist=list() if searchword: - newslist = self.se.QueryPhrase(searchword,False) - return render.header(searchword,newslist) + newslist = self.se.QueryByTime(searchword) + return render.index(searchword,newslist) class news: def __init__(self): self.se = Search() def GET(self): - searchword = web.input().searchword - newslist=list() - if searchword: - newslist = self.se.QueryPhrase(searchword,False) - return render.header(searchword,newslist) + data = web.input() + if data: + ID = data.id + else: + ID='' + news = self.se.QueryById(ID) + return render.news(news) if __name__ == "__main__": app = web.application(urls,globals()) diff --git a/web/main.pyc b/web/main.pyc index 5cd0b1f52354874a3973676614c6f02f3a4840b4..590d28eacb444149a29eb49c0f637375703b257c 100644 GIT binary patch delta 458 zcma)%u}T9$5QhKR&F&@Pa)>cyf_4Wsf}n-nX<-`CRnSTZ-W56Uz`GL(Tu6~N-GT2R zHa>>nd)W8@I&+|DE%x7?;s0m$dk)?LPk;5gtJU6%_f3ly0L|x^PjSOi0x4k$%n21C zABm<4bA`+zCV7;)F=$i@`6()nw2&Gpmu%3;c#cKtNvC47!eyv<_!&F&=syYEAu delta 419 zcmcJKy-LJT5QS%Me(ol2vVtfomKNzmi>($x0^2D|EbNr1fhEWmNy;o1`v@0&581}| zvA56%&~vuZ2e3FF=N@L}&b*~Bsr9~+`1tk)=xK(Jzhk zD$Q7W - + @@ -32,7 +32,7 @@ $if len(newslist) > 0: 时间:$news['time'] $news['title']
- $news['content'] ... 查看全文>>> + $news['content'] ... 查看全文>>>

原始网页链接:$news['url']
diff --git a/web/templates/list.html b/web/templates/list.html deleted file mode 100644 index e69de29..0000000 diff --git a/web/templates/news.html b/web/templates/news.html index d5d6c6f..bc08f01 100644 --- a/web/templates/news.html +++ b/web/templates/news.html @@ -1,31 +1,42 @@ +$def with(news) 新闻聚合搜索引擎 - + + + - - -
-
-

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.

- -

Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.

-
- -
+ +$if news: +
+
+
+
+ $news['time'] $news['title'] +
+
+ $news['content'] +

+ 原始网页链接:$news['url'] +
+
+
+
+
+
相关新闻
+
+
    +
  • AAAA
  • +
  • BBBB
  • +
  • CCCC
  • +
+
+
+
+
diff --git a/web/templates/test.html b/web/templates/test.html deleted file mode 100644 index b17784a..0000000 --- a/web/templates/test.html +++ /dev/null @@ -1,10 +0,0 @@ - - - -新闻聚合搜索 -
- - Search -
\ No newline at end of file