乙個爬電商資料並實現搜尋的例子

2021-09-01 20:08:06 字數 998 閱讀 5170

這是乙個抓取電商商品資訊,並提供搜尋介面的例子。

採用的技術:

**管理github

持續整合gradle

web框架rose3.0(基於spring3.0)

資料庫mysql

商品抓取id遍歷,jsoup解析網頁

搜尋lucene

現在的介面:

抓取資料:

,把易迅的資料抓取下來,只抓一萬個左右,放在資料庫中

生成索引:

,把資料庫中的資料用lucene來做索引

搜尋結果:http://localhost/search?keyword=midea&begin=0&count=20&cate=飲水機&minprice=100.1&maxprice=2000

必填:keyword 是關鍵字,對名稱和描述有用,begin和count是對結果翻頁

選填:cate是分類,也是用lucene做的索引,還有就是**區間的選擇

搜尋建議:http://localhost/suggest?begin=0&count=100&keyword=meiru

是對名稱做了最前匹配,包括名稱的拼音和首字母

檢視所有資料:

beginid:開始的id,count:數量

現在的電商中,京東和易迅id是順序的,amazon和噹噹的id是hash的,所以我的這個demo只能抓京東和易迅的資料。但是京東的**不是直接展示在頁面上,而是通過js單獨發請求得到的,比較麻煩,第一版demo暫時只能抓取易迅的資料。

搜尋分搜尋建議和搜尋結果,搜尋建議是把商品名稱做了漢子,漢子轉換成全拼及首字母的字首匹配;搜尋結果是對商品名稱和描述做了全文索引。

github位址

gradle很好用,不會自己學學

有建議歡迎討論

乙個lucene搜尋高亮顯示的例子。

above,create documents with two fields,one with term vectors tv and one without notv indexsearcher searcher new indexsearcher directory queryparser pa...

乙個搜尋路徑的例子程式 注釋

include stdio.h include stdio.h include dirent.h include string.h include sys stat.h void show dir char dir,int depth chdir dir 進去當前操作目錄,當有子目錄時遞迴呼叫使用的...

乙個JDBC實現批量刪除的例子

資料庫 sqlserver2005 伺服器 tomcat6.0 開發工具 myeclipse6.0 採用框架 struts1.2 貼出完整 建立sql指令碼 create table dbo batch id int identity 1,1 not null,name varchar 50 nul...