• SpringBoot整合ElasticSearch,抓取JD数据案例


    (1)创建一个Springboot工程并加入相关的依赖

    (1条消息) SpringBoot架构_lqh12138的博客-CSDN博客

    1. <dependencies>
    2. <dependency>
    3. <groupId>com.alibabagroupId>
    4. <artifactId>fastjsonartifactId>
    5. <version>1.2.75version>
    6. dependency>
    7. <dependency>
    8. <groupId>org.springframework.bootgroupId>
    9. <artifactId>spring-boot-starter-data-elasticsearchartifactId>
    10. dependency>
    11. <dependency>
    12. <groupId>org.springframework.bootgroupId>
    13. <artifactId>spring-boot-starter-webartifactId>
    14. dependency>
    15. <dependency>
    16. <groupId>org.projectlombokgroupId>
    17. <artifactId>lombokartifactId>
    18. <optional>trueoptional>
    19. dependency>
    20. <dependency>
    21. <groupId>org.springframework.bootgroupId>
    22. <artifactId>spring-boot-starter-testartifactId>
    23. <scope>testscope>
    24. dependency>
    25. dependencies>

    (2) 创建一个配置,获取ES工具类对象。

    1. @Configuration
    2. public class ESConfig {
    3. //该对象可以对我们的ES进行相关的操作
    4. @Bean
    5. public RestHighLevelClient restHighLevelClient(){
    6. RestHighLevelClient client = new RestHighLevelClient(
    7. RestClient.builder(new HttpHost("127.0.0.1",9200,"http")));
    8. return client;
    9. }
    10. }

    (3)进行相关对ElasticSearch操作

    3.1 操作索引---创建索引

    1. //PUT /索引名称
    2. @Test
    3. void testCreateIndex() throws Exception {
    4. //该类把创建索引的信息都封装到该类中
    5. CreateIndexRequest createIndexRequest=new CreateIndexRequest("qy151-index");
    6. CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
    7. System.out.println(createIndexResponse.isAcknowledged());
    8. }

    3.2 操作索引--删除索引

    1. @Test
    2. public void testDeleteIndex() throws Exception {
    3. DeleteIndexRequest deleteIndexRequest=new DeleteIndexRequest("qy151-index");
    4. AcknowledgedResponse delete = client.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
    5. System.out.println(delete.isAcknowledged());
    6. }

    3.3 索引操作--判断索引是否存在

    1. @Test
    2. public void testIndexExists() throws Exception{
    3. GetIndexRequest getIndexRequest=new GetIndexRequest("qy151-index");
    4. boolean exists = client.indices().exists(getIndexRequest, RequestOptions.DEFAULT);
    5. System.out.println(exists);
    6. }

    (4)操作文档---添加文档

    1. //添加文档--PUT /索引/1 {name:"",age:"",address:""}
    2. @Test
    3. public void testInsertDoc() throws Exception{
    4. IndexRequest indexRequest=new IndexRequest("qy151-index");
    5. indexRequest.id("1");//指定文档的id
    6. //指定文档的内容:String文档的json内容,XContentType xContentType:以什么格式
    7. indexRequest.source(JSON.toJSONString(new User("张三","北京",22)), XContentType.JSON);
    8. IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
    9. System.out.println(indexResponse.getResult());
    10. }

    (5)查询文档--id

    1. //获取文档 GET /索引/_doc/1
    2. @Test
    3. public void testGetDoc() throws Exception{
    4. GetRequest indexRequest=new GetRequest("qy151-index");
    5. indexRequest.id("1");
    6. GetResponse getResponse = client.get(indexRequest, RequestOptions.DEFAULT);
    7. String string = getResponse.getSourceAsString();
    8. User user = JSON.parseObject(string, User.class);
    9. Map map = getResponse.getSourceAsMap();
    10. System.out.println(map.get("address"));
    11. }

    (6)判断文档是否存在

    1. //判断索引文档是否存在
    2. @Test
    3. public void testDocExist() throws Exception{
    4. GetRequest indexRequest=new GetRequest("qy151-index");
    5. indexRequest.id("2");
    6. boolean exists = client.exists(indexRequest, RequestOptions.DEFAULT);
    7. System.out.println(exists);
    8. }

    (7)删除文档

    1. //文档操作---删除文档
    2. @Test
    3. public void testDeleteDoc() throws Exception{
    4. DeleteRequest deleteRequest=new DeleteRequest("qy151-index");
    5. deleteRequest.id("1");
    6. DeleteResponse delete = client.delete(deleteRequest,RequestOptions.DEFAULT);
    7. System.out.println(delete.getResult());
    8. }

    (8)修改文档

    1. @Test
    2. public void testUpdateDoc()throws Exception{
    3. UpdateRequest updateRequest=new UpdateRequest("qy151-index","1");
    4. User user = new User();
    5. user.setName("刘德华");
    6. updateRequest.doc(JSON.toJSONString(user), XContentType.JSON);
    7. UpdateResponse update = client.update(updateRequest, RequestOptions.DEFAULT);
    8. System.out.println(update.getResult());
    9. }

    (9)批量添加文档

    1. //批量添加文档
    2. @Test
    3. public void testBuck() throws Exception{
    4. BulkRequest bulk=new BulkRequest("qy151-index");
    5. List list=new ArrayList<>();
    6. list.add(new User("2","张三","北京",22));
    7. list.add(new User("3","张三他爸","上海",22));
    8. list.add(new User("4","李四","杭州",22));
    9. list.add(new User("5","李四他妈","广州",22));
    10. list.add(new User("6","王五","南京",22));
    11. //list.stream().forEach(item->bulk.add(new IndexRequest().id(item.getId()).source(JSON.toJSONString(item),XContentType.JSON)));
    12. for(User user:list){
    13. IndexRequest indexRequest=new IndexRequest();
    14. indexRequest.id(user.getId());
    15. indexRequest.source(JSON.toJSONString(user),XContentType.JSON);
    16. bulk.add(indexRequest);
    17. }
    18. BulkResponse bulkResponse = client.bulk(bulk,RequestOptions.DEFAULT);
    19. System.out.println(bulkResponse.hasFailures());
    20. }

    (10)复杂查询

    1. //搜索查询---GET /索引/_search
    2. // {
    3. // "query":{
    4. // "":{}
    5. // },
    6. // "from":
    7. // "size":
    8. // "_source":["",""],
    9. // "sort":{}
    10. // }
    11. //1. 搜索请求对象SearchRequest
    12. //2. 构建一个条件对象SearchSourceBuilder
    13. //3. 把条件对象放入搜索请求对象中
    14. //4. 执行搜索功能
    15. @Test
    16. public void testSearch() throws Exception{
    17. //
    18. SearchRequest searchRequest=new SearchRequest("qy151-index");
    19. //创建一个条件对象
    20. SearchSourceBuilder sourceBuilder=new SearchSourceBuilder();
    21. TermQueryBuilder matchQuery = QueryBuilders.termQuery("name", "张");
    22. sourceBuilder.query(matchQuery);
    23. //分页
    24. sourceBuilder.from(0);
    25. sourceBuilder.size(1);
    26. //排序
    27. // sourceBuilder.sort("age");
    28. //高亮
    29. HighlightBuilder highlightBuilder=new HighlightBuilder();
    30. highlightBuilder.field("name");
    31. highlightBuilder.preTags("");
    32. highlightBuilder.postTags("");
    33. sourceBuilder.highlighter(highlightBuilder);
    34. searchRequest.source(sourceBuilder);
    35. SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
    36. System.out.println("总条数:"+searchResponse.getHits().getTotalHits().value);
    37. SearchHit[] hits = searchResponse.getHits().getHits();
    38. Arrays.stream(hits).forEach(item-> System.out.println(item.getSourceAsString()));
    39. Arrays.stream(hits).forEach(item-> System.out.println(item.getHighlightFields()));
    40. }

    综合案例--京东搜索

    后端数据

    所需的包目录

    pom.xml

    1. "1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    4. <modelVersion>4.0.0modelVersion>
    5. <parent>
    6. <groupId>org.springframework.bootgroupId>
    7. <artifactId>spring-boot-starter-parentartifactId>
    8. <version>2.3.12.RELEASEversion>
    9. <relativePath/>
    10. parent>
    11. <groupId>com.lqhgroupId>
    12. <artifactId>day0816-JDartifactId>
    13. <version>0.0.1-SNAPSHOTversion>
    14. <name>day0816-JDname>
    15. <description>day0816-JDdescription>
    16. <properties>
    17. <java.version>1.8java.version>
    18. properties>
    19. <dependencies>
    20. <dependency>
    21. <groupId>org.springframework.bootgroupId>
    22. <artifactId>spring-boot-starter-data-elasticsearchartifactId>
    23. dependency>
    24. <dependency>
    25. <groupId>org.springframework.bootgroupId>
    26. <artifactId>spring-boot-starter-webartifactId>
    27. dependency>
    28. <dependency>
    29. <groupId>org.projectlombokgroupId>
    30. <artifactId>lombokartifactId>
    31. <optional>trueoptional>
    32. dependency>
    33. <dependency>
    34. <groupId>org.springframework.bootgroupId>
    35. <artifactId>spring-boot-starter-testartifactId>
    36. <scope>testscope>
    37. dependency>
    38. <dependency>
    39. <groupId>org.jsoupgroupId>
    40. <artifactId>jsoupartifactId>
    41. <version>1.11.3version>
    42. dependency>
    43. <dependency>
    44. <groupId>com.alibabagroupId>
    45. <artifactId>fastjsonartifactId>
    46. <version>2.0.5version>
    47. dependency>
    48. dependencies>
    49. <build>
    50. <plugins>
    51. <plugin>
    52. <groupId>org.springframework.bootgroupId>
    53. <artifactId>spring-boot-maven-pluginartifactId>
    54. <configuration>
    55. <excludes>
    56. <exclude>
    57. <groupId>org.projectlombokgroupId>
    58. <artifactId>lombokartifactId>
    59. exclude>
    60. excludes>
    61. configuration>
    62. plugin>
    63. plugins>
    64. build>
    65. project>

     HttpParseUtil类 抓取京东的商品数据

    1. package com.lqh.utils;
    2. import com.lqh.entity.Product;
    3. import org.jsoup.Jsoup;
    4. import org.jsoup.nodes.Document;
    5. import org.jsoup.nodes.Element;
    6. import org.jsoup.select.Elements;
    7. import java.net.URL;
    8. import java.util.ArrayList;
    9. import java.util.List;
    10. public class HttpParseUtil {
    11. public static List searchGoods(String goods){
    12. String url="https://search.jd.com/Search?keyword="+goods;
    13. try {
    14. Document document = Jsoup.parse(new URL(url), 30000);
    15. //获取所搜索的整个网页
    16. //System.out.println(document);
    17. Element goodsList = document.getElementById("J_goodsList");
    18. //获取所搜内容的部分
    19. //System.out.println(goodsList);
    20. Elements li = goodsList.getElementsByTag("li");
    21. //System.out.println(li);
    22. List list = new ArrayList<>();
    23. for (Element element : li) {
    24. String price = element.getElementsByClass("p-price").eq(0).text();
    25. String name = element.getElementsByClass("p-name").eq(0).text();
    26. String img = element.getElementsByTag("img").eq(0).attr("data-lazy-img");
    27. list.add(new Product(name, price, img));
    28. }
    29. return list;
    30. }catch (Exception e){
    31. e.printStackTrace();
    32. }
    33. return null;
    34. }
    35. public static void main(String[] args) {
    36. List list = HttpParseUtil.searchGoods("华为");
    37. System.out.println(list);
    38. }
    39. }

    CommonResult类

    1. package com.lqh.utils;
    2. import lombok.AllArgsConstructor;
    3. import lombok.Data;
    4. import lombok.NoArgsConstructor;
    5. @Data
    6. @AllArgsConstructor
    7. @NoArgsConstructor
    8. public class CommonResult {
    9. private Integer code;
    10. private String msg;
    11. private Object data;
    12. }

    application.yml 配置文件

    1. server:
    2. port: 8001

    ProductController类

    1. package com.lqh.controller;
    2. import com.lqh.server.ProductServer;
    3. import com.lqh.utils.CommonResult;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.web.bind.annotation.*;
    6. import java.util.List;
    7. import java.util.Map;
    8. @RestController
    9. @RequestMapping("/product")
    10. @CrossOrigin
    11. public class ProductController {
    12. @Autowired
    13. private ProductServer productServer;
    14. @GetMapping("/export/{keyword}")
    15. public CommonResult exportProduct(@PathVariable String keyword) throws Exception{
    16. String result = productServer.exportGoods(keyword);
    17. if(result.contains("成功")) {
    18. return new CommonResult(200, result, null);
    19. }else return new CommonResult(500,result,null);
    20. }
    21. @GetMapping("/search/{currentPage}/{pageSize}/{keyword}")
    22. public CommonResult searchProduct(@PathVariable Integer currentPage,@PathVariable Integer pageSize,@PathVariable String keyword) throws Exception{
    23. List> list = productServer.searchGoods(currentPage,pageSize,keyword);
    24. if(list!=null){
    25. return new CommonResult(200,"商品搜索成功",list);
    26. }else{
    27. return new CommonResult(500,"没有查到该商品",null);
    28. }
    29. }
    30. }

    Product 实体类 这里只要商品的名字、价格、图片

    1. package com.lqh.entity;
    2. import lombok.AllArgsConstructor;
    3. import lombok.Data;
    4. import lombok.NoArgsConstructor;
    5. @Data
    6. @AllArgsConstructor
    7. @NoArgsConstructor
    8. public class Product {
    9. private String name;
    10. private String price;
    11. private String imgUrl;
    12. }

    ProductServer

    1. package com.lqh.server;
    2. import com.alibaba.fastjson.JSON;
    3. import com.lqh.entity.Product;
    4. import com.lqh.utils.HttpParseUtil;
    5. import org.elasticsearch.action.bulk.BulkRequest;
    6. import org.elasticsearch.action.bulk.BulkResponse;
    7. import org.elasticsearch.action.index.IndexRequest;
    8. import org.elasticsearch.action.search.SearchRequest;
    9. import org.elasticsearch.action.search.SearchResponse;
    10. import org.elasticsearch.client.RequestOptions;
    11. import org.elasticsearch.client.RestHighLevelClient;
    12. import org.elasticsearch.common.text.Text;
    13. import org.elasticsearch.common.xcontent.XContentType;
    14. import org.elasticsearch.index.query.MatchQueryBuilder;
    15. import org.elasticsearch.index.query.QueryBuilders;
    16. import org.elasticsearch.search.SearchHit;
    17. import org.elasticsearch.search.SearchHits;
    18. import org.elasticsearch.search.builder.SearchSourceBuilder;
    19. import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
    20. import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
    21. import org.springframework.beans.factory.annotation.Autowired;
    22. import org.springframework.stereotype.Service;
    23. import java.util.ArrayList;
    24. import java.util.HashMap;
    25. import java.util.List;
    26. import java.util.Map;
    27. @Service
    28. public class ProductServer {
    29. @Autowired
    30. private RestHighLevelClient client;
    31. public String exportGoods(String keyword) throws Exception{
    32. BulkRequest request=new BulkRequest("lqh-jd");
    33. List list = HttpParseUtil.searchGoods(keyword);
    34. for (Product product : list) {
    35. IndexRequest indexRequest=new IndexRequest();
    36. indexRequest.source(JSON.toJSONString(product), XContentType.JSON);
    37. request.add(indexRequest);
    38. }
    39. BulkResponse response = client.bulk(request, RequestOptions.DEFAULT);
    40. if(response.hasFailures()){
    41. return "批量添加失败";
    42. }else{
    43. return "批量添加成功";
    44. }
    45. }
    46. public List> searchGoods(Integer currentPage,Integer pageSize,String keyword) throws Exception{
    47. //exportGoods(keyword);
    48. SearchRequest request=new SearchRequest("lqh-jd");
    49. SearchSourceBuilder sourceBuilder=new SearchSourceBuilder();
    50. MatchQueryBuilder matchQuery = QueryBuilders.matchQuery("name", keyword);
    51. sourceBuilder.query(matchQuery);
    52. sourceBuilder.from(currentPage);
    53. sourceBuilder.size(pageSize);
    54. HighlightBuilder highlightBuilder=new HighlightBuilder();
    55. highlightBuilder.field("name");
    56. highlightBuilder.preTags("");
    57. highlightBuilder.postTags("");
    58. sourceBuilder.highlighter(highlightBuilder);
    59. request.source(sourceBuilder);
    60. SearchResponse response = client.search(request, RequestOptions.DEFAULT);
    61. SearchHits hits = response.getHits();
    62. SearchHit[] searchHits = hits.getHits();
    63. List> list=new ArrayList<>();
    64. long total = hits.getTotalHits().value;
    65. /*Map value=new HashMap<>();
    66. value.put("total",total);
    67. list.add(value);*/
    68. for (SearchHit hit : searchHits) {
    69. Map map = hit.getSourceAsMap();
    70. Map highlightFields = hit.getHighlightFields();
    71. HighlightField name = highlightFields.get("name");
    72. Text[] fragments = name.getFragments();
    73. StringBuilder string=new StringBuilder();
    74. for (Text text : fragments) {
    75. string.append(text);
    76. }
    77. map.put("name",string);
    78. map.put("total",total);
    79. list.add(map);
    80. }
    81. return list;
    82. }
    83. }

    前端数据

    页面

    1. <template>
    2. <div class="page">
    3. <div id="app" class=" mallist tmall- page-not-market ">
    4. <div id="header" class=" header-list-app">
    5. <div class="headerLayout">
    6. <div class="headerCon ">
    7. <h1 id="mallLogo">
    8. h1>
    9. <div class="header-extra">
    10. <div id="mallSearch" class="mall-search">
    11. <form name="searchTop" class="mallSearch-form clearfix">
    12. <fieldset>
    13. <legend>天猫搜索legend>
    14. <div class="mallSearch-input clearfix">
    15. <div class="s-combobox" id="s-combobox-685">
    16. <div class="s-combobox-input-wrap">
    17. <input v-model="keyword" type="text" autocomplete="off" id="mq"
    18. class="s-combobox-input" aria-haspopup="true">
    19. div>
    20. div>
    21. <button type="submit" @click.prevent="searchKey" id="searchbtn">搜索button>
    22. div>
    23. fieldset>
    24. form>
    25. <ul class="relKeyTop">
    26. <li><a>老闫说Javaa>li>
    27. <li><a>老闫说前端a>li>
    28. <li><a>老闫说Linuxa>li>
    29. <li><a>老闫说大数据a>li>
    30. <li><a>老闫聊理财a>li>
    31. ul>
    32. div>
    33. div>
    34. div>
    35. div>
    36. div>
    37. <div id="content">
    38. <div class="main">
    39. <form class="navAttrsForm">
    40. <div class="attrs j_NavAttrs" style="display:block">
    41. <div class="brandAttr j_nav_brand">
    42. <div class="j_Brand attr">
    43. <div class="attrKey">
    44. 品牌
    45. div>
    46. <div class="attrValues">
    47. <ul class="av-collapse row-2">
    48. <li><a href="#"> 老闫说 a>li>
    49. <li><a href="#"> Java a>li>
    50. ul>
    51. div>
    52. div>
    53. div>
    54. div>
    55. form>
    56. <div class="filter clearfix">
    57. <a class="fSort fSort-cur">综合<i class="f-ico-arrow-d">i>a>
    58. <a class="fSort">人气<i class="f-ico-arrow-d">i>a>
    59. <a class="fSort">新品<i class="f-ico-arrow-d">i>a>
    60. <a class="fSort">销量<i class="f-ico-arrow-d">i>a>
    61. <a class="fSort">价格<i class="f-ico-triangle-mt">i><i class="f-ico-triangle-mb">i>a>
    62. div>
    63. <div class="view grid-nosku" >
    64. <div class="product" v-for="item in results">
    65. <div class="product-iWrap">
    66. <div class="productImg-wrap">
    67. <a class="productImg">
    68. <img :src="item.imgUrl">
    69. a>
    70. div>
    71. <p class="productPrice">
    72. <em>{{item.price}}em>
    73. p>
    74. <p class="productTitle">
    75. <a v-html="item.name"> a>
    76. p>
    77. <div class="productShop">
    78. <span>店铺: 老闫说Java span>
    79. div>
    80. <p class="productStatus">
    81. <span>月成交<em>999笔em>span>
    82. <span>评价 <a>3a>span>
    83. p>
    84. div>
    85. div>
    86. div>
    87. div>
    88. <el-pagination
    89. @size-change="handleSizeChange"
    90. @current-change="handleCurrentChange"
    91. :current-page="currentPage"
    92. :page-sizes="pageSizes"
    93. :page-size="pageSize"
    94. layout="total, sizes, prev, pager, next, jumper"
    95. :total="total">
    96. el-pagination>
    97. div>
    98. div>
    99. div>
    100. template>
    101. <script>
    102. export default {
    103. name: "jd",
    104. data(){
    105. return {
    106. keyword: '', // 搜索的关键字
    107. results:[] ,// 后端返回的结果
    108. //当前显示的页码变量,默认为第一页
    109. currentPage:1,
    110. //
    111. pageSizes:[5,10,20,30,40],
    112. //进入页面时,每页显示5条数据
    113. pageSize:5,
    114. //
    115. total:0,
    116. }
    117. },
    118. methods:{
    119. searchKey(){
    120. var keyword = this.keyword;
    121. this.$http.get('/product/search/'+this.currentPage+"/"+this.pageSize+"/"+this.keyword).then(response=>{
    122. /*this.total=response.data.data[0].total
    123. var splice = response.data.data.splice(1,response.data.data.length);
    124. this.results=splice*/
    125. console.log(response.data.data)
    126. this.total=response.data.data[0].total
    127. this.results=response.data.data
    128. })
    129. },
    130. /*每页显示的条数大小改变时触发的方法*/
    131. handleSizeChange(val) {
    132. this.pageSize=val;
    133. this.searchKey()
    134. console.log('每页 '+val +'条');
    135. },
    136. /*页码改变时触发的方法*/
    137. handleCurrentChange(val) {
    138. this.currentPage=val
    139. this.searchKey()
    140. console.log('当前页:'+ val);
    141. },
    142. }
    143. }
    144. script>
    145. <style>
    146. /*** uncss> filename: http://localhost:9090/css/global.css ***/body,button,fieldset,form,h1,input,legend,li,p,ul{margin:0;padding:0}body,button,input{font:12px/1.5 tahoma,arial,"\5b8b\4f53";-ms-overflow-style:scrollbar}button,h1,input{font-size:100%}em{font-style:normal}ul{list-style:none}a{text-decoration:none}a:hover{text-decoration:underline}legend{color:#000}fieldset,img{border:0}#content,#header{margin-left:auto;margin-right:auto}html{zoom:expression(function(ele){ ele.style.zoom = "1"; document.execCommand("BackgroundImageCache", false, true); }(this))}@font-face{font-family:mui-global-iconfont;src:url(//at.alicdn.com/t/font_1401963178_8135476.eot);src:url(//at.alicdn.com/t/font_1401963178_8135476.eot?#iefix) format('embedded-opentype'),url(//at.alicdn.com/t/font_1401963178_8135476.woff) format('woff'),url(//at.alicdn.com/t/font_1401963178_8135476.ttf) format('truetype'),url(//at.alicdn.com/t/font_1401963178_8135476.svg#iconfont) format('svg')}#mallPage{width:auto;min-width:990px;background-color:transparent}#content{width:990px;margin:auto}#mallLogo{float:left;z-index:9;padding-top:28px;width:280px;height:64px;line-height:64px;position:relative}.page-not-market #mallLogo{width:400px}.clearfix:after,.clearfix:before,.headerCon:after,.headerCon:before{display:table;content:"";overflow:hidden}#mallSearch legend{display:none}.clearfix:after,.headerCon:after{clear:both}.clearfix,.headerCon{zoom:1}#mallPage #header{margin-top:-30px;width:auto;margin-bottom:0;min-width:990px;background:#fff}#header{height:122px;margin-top:-26px!important;background:#fff;min-width:990px;width:auto!important;position:relative;z-index:1000}#mallSearch #mq,#mallSearch fieldset,.mallSearch-input{position:relative}.headerLayout{width:990px;padding-top:26px;margin:0 auto}.header-extra{overflow:hidden}#mallSearch{float:right;padding-top:25px;width:390px;overflow:hidden}.mallSearch-form{border:solid #FF0036;border-width:3px 0 3px 3px}.mallSearch-input{background:#fff;height:30px}#mallSearch #mq{color:#000;margin:0;z-index:2;width:289px;height:20px;line-height:20px;padding:5px 3px 5px 5px;outline:0;border:none;font-weight:900;background:url(data:image/gif;base64,R0lGODlhAQADAJEAAObm5t3d3ff39wAAACH5BAAAAAAALAAAAAABAAMAAAICDFQAOw==) repeat-x;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}#mallSearch button{position:absolute;right:0;top:0;width:90px;border:0;font-size:16px;letter-spacing:4px;cursor:pointer;color:#fff;background-color:#FF0036;height:30px;overflow:hidden;font-family:'\5FAE\8F6F\96C5\9ED1',arial,"\5b8b\4f53"}#mallSearch .s-combobox{height:30px}#mallSearch .s-combobox .s-combobox-input:focus{outline:0}button::-moz-focus-inner{border:0;padding:0;margin:0}.page-not-market #mallSearch{width:540px!important}.page-not-market #mq{width:439px!important}
    147. /*** uncss> filename: http://localhost:9090/css/test.css ***/#mallSearch{float:none}.page-not-market #mallLogo{width:280px}.header-list-app #mallSearch{width:448px!important}.header-list-app #mq{width:347px!important}@media (min-width:1210px){#header .headerCon,#header .headerLayout,.main{width:1190px!important}.header-list-app #mallSearch{width:597px!important}.header-list-app #mq{width:496px!important}}@media (min-width:600px) and (max-width:800px) and (orientation:portrait){.pg .page{min-width:inherit!important}.pg #mallPage,.pg #mallPage #header{min-width:740px!important}.pg #header .headerCon,.pg #header .headerLayout,.pg .main{width:740px!important}.pg #mallPage #mallLogo{width:260px}.pg #header{min-width:inherit}.pg #mallSearch .mallSearch-input{padding-right:95px}.pg #mallSearch .s-combobox{width:100%!important}.pg #mallPage .header-list-app #mallSearch{width:auto!important}.pg #mallPage .header-list-app #mallSearch #mq{width:100%!important;padding:5px 0 5px 5px}}i{font-style:normal}.main,.page{position:relative}.page{overflow:hidden}@font-face{font-family:tm-list-font;src:url(//at.alicdn.com/t/font_1442456441_338337.eot);src:url(//at.alicdn.com/t/font_1442456441_338337.eot?#iefix) format('embedded-opentype'),url(//at.alicdn.com/t/font_1442456441_338337.woff) format('woff'),url(//at.alicdn.com/t/font_1442456441_338337.ttf) format('truetype'),url(//at.alicdn.com/t/font_1442456441_338337.svg#iconfont) format('svg')}::selection{background:rgba(0,0,0,.1)}*{-webkit-tap-highlight-color:rgba(0,0,0,.3)}b{font-weight:400}.page{background:#fff;min-width:990px}#content{margin:0!important;width:100%!important}.main{margin:auto;width:990px}.main img{-ms-interpolation-mode:bicubic}.fSort i{background:url(//img.alicdn.com/tfs/TB1XClLeAY2gK0jSZFgXXc5OFXa-165-206.png) 9999px 9999px no-repeat}#mallSearch .s-combobox{width:auto}::-ms-clear,::-ms-reveal{display:none}.attrKey{white-space:nowrap;text-overflow:ellipsis}.attrs{border-top:1px solid #E6E2E1}.attrs a{outline:0}.attr{background-color:#F7F5F5;border-color:#E6E2E1 #E6E2E1 #D1CCC7;border-style:solid solid dotted;border-width:0 1px 1px}.attr ul:after,.attr:after{display:block;clear:both;height:0;content:' '}.attrKey{float:left;padding:7px 0 0;width:10%;color:#B0A59F;text-indent:13px}.attrKey{display:block;height:16px;line-height:16px;overflow:hidden}.attrValues{position:relative;float:left;background-color:#FFF;width:90%;padding:4px 0 0;overflow:hidden}.attrValues ul{position:relative;margin-right:105px;margin-left:25px}.attrValues ul.av-collapse{overflow:hidden}.attrValues li{float:left;height:22px;line-height:22px}.attrValues li a{position:relative;color:#806F66;display:inline-block;padding:1px 20px 1px 4px;line-height:20px;height:20px;white-space:nowrap}.attrValues li a:hover{color:#ff0036;text-decoration:none}.brandAttr .attr{border:2px solid #D1CCC7;margin-top:-1px}.brandAttr .attrKey{padding-top:9px}.brandAttr .attrValues{padding-top:6px}.brandAttr .av-collapse{overflow:hidden;max-height:60px}.brandAttr li{margin:0 8px 8px 0}.brandAttr li a{text-overflow:ellipsis;overflow:hidden}.navAttrsForm{position:relative}.relKeyTop{padding:4px 0 0;margin-left:-13px;height:16px;overflow:hidden;width:100%}.relKeyTop li{display:inline-block;border-left:1px solid #ccc;line-height:1.1;padding:0 12px}.relKeyTop li a{color:#999}.relKeyTop li a:hover{color:#ff0036;text-decoration:none}.filter i{display:inline-block;overflow:hidden}.filter{margin:10px 0;padding:5px;position:relative;z-index:10;background:#faf9f9;color:#806f66}.filter i{position:absolute}.filter a{color:#806f66;cursor:pointer}.filter a:hover{color:#ff0036;text-decoration:none}.fSort{float:left;height:22px;line-height:20px;line-height:24px\9;border:1px solid #ccc;background-color:#fff;z-index:10}.fSort{position:relative}.fSort{display:inline-block;margin-left:-1px;overflow:hidden;padding:0 15px 0 5px}.fSort:hover,a.fSort-cur{color:#ff0036;background:#F1EDEC}.fSort i{top:6px;right:5px;width:7px;height:10px;line-height:10px}.fSort .f-ico-arrow-d{background-position:-22px -23px}.fSort-cur .f-ico-arrow-d,.fSort:hover .f-ico-arrow-d{background-position:-30px -23px}i.f-ico-triangle-mb,i.f-ico-triangle-mt{border:4px solid transparent;height:0;width:0}i.f-ico-triangle-mt{border-bottom:4px solid #806F66;top:2px}i.f-ico-triangle-mb{border-top:4px solid #806F66;border-width:3px\9;right:6px\9;top:12px}:root i.f-ico-triangle-mb{border-width:4px\9;right:5px\9}i.f-ico-triangle-mb,i.f-ico-triangle-mt{border:4px solid transparent;height:0;width:0}i.f-ico-triangle-mt{border-bottom:4px solid #806F66;top:2px}i.f-ico-triangle-mb{border-top:4px solid #806F66;border-width:3px\9;right:6px\9;top:12px}:root i.f-ico-triangle-mb{border-width:4px\9;right:5px\9}.view:after{clear:both;content:' '}.productImg,.productPrice em b{vertical-align:middle}.product{position:relative;float:left;padding:0;margin:0 0 20px;line-height:1.5;overflow:visible;z-index:1}.product:hover{overflow:visible;z-index:3;background:#fff}.product-iWrap{position:absolute;background-color:#fff;margin:0;padding:4px 4px 0;font-size:0;border:1px solid #f5f5f5;border-radius:3px}.product-iWrap *{font-size:12px}.product:hover .product-iWrap{height:auto;margin:-3px;border:4px solid #ff0036;border-radius:0;-webkit-transition:border-color .2s ease-in;-moz-transition:border-color .2s ease-in;-ms-transition:border-color .2s ease-in;-o-transition:border-color .2s ease-in;transition:border-color .2s ease-in}.productPrice,.productShop,.productStatus,.productTitle{display:block;overflow:hidden;margin-bottom:3px}.view:after{display:block}.view{margin-top:10px}.view:after{height:0}.productImg-wrap{display:table;table-layout:fixed;height:210px;width:100%;padding:0;margin:0 0 5px}.productImg-wrap a,.productImg-wrap img{max-width:100%;max-height:210px}.productImg{display:table-cell;width:100%;text-align:center}.productImg img{display:block;margin:0 auto}.productPrice{font-family:arial,verdana,sans-serif!important;color:#ff0036;font-size:14px;height:30px;line-height:30px;margin:0 0 5px;letter-spacing:normal;overflow:inherit!important;white-space:nowrap}.productPrice *{height:30px}.productPrice em{float:left;font-family:arial;font-weight:400;font-size:20px;color:#ff0036}.productPrice em b{margin-right:2px;font-weight:700;font-size:14px}.productTitle{display:block;color:#666;height:14px;line-height:12px;margin-bottom:3px;word-break:break-all;font-size:0;position:relative}.productTitle *{font-size:12px;font-family:\5FAE\8F6F\96C5\9ED1;line-height:14px}.productTitle a{color:#333}.productTitle a:hover{color:#ff0036!important}.productTitle a:visited{color:#551A8B!important}.product:hover .productTitle{height:14px}.productShop{position:relative;height:22px;line-height:20px;margin-bottom:5px;color:#999;white-space:nowrap;overflow:visible}.productStatus{position:relative;height:32px;border:none;border-top:1px solid #eee;margin-bottom:0;color:#999}.productStatus span{float:left;display:inline-block;border-right:1px solid #eee;width:39%;padding:10px 1px;margin-right:6px;line-height:12px;text-align:left;white-space:nowrap}.productStatus a,.productStatus em{margin-top:-8px;font-family:arial;font-size:12px;font-weight:700}.productStatus em{color:#b57c5b}.productStatus a{color:#38b}.productImg-wrap{position:relative}.product-iWrap{min-height:98%;width:210px}.view{padding-left:5px;padding-right:5px}.view{width:1023px}.view .product{width:220px;margin-right:33px}@media (min-width:1210px){.view{width:1210px;padding-left:5px;padding-right:5px}.view .product{width:220px;margin-right:20px}}@media (min-width:600px) and (max-width:800px) and (orientation:portrait){.view{width:775px;padding-left:5px;padding-right:5px}.view .product{width:220px;margin-right:35px}}.product{height:372px}.grid-nosku .product{height:333px}
    148. style>

    测试结果

  • 相关阅读:
    8 个精彩的免费 G​​IS 软件资源分享
    ChatGPT引领:打造独具魅力的论文
    为什么需要在微服务中使用链路追踪?Spring Cloud 可以选择哪些微服务链路追踪方案?
    RocketMQ源码阅读(十一)AllocateMessageQueueConsistentHash一致性hash
    计组 | 交叉编址 & 流水线
    Deformable Convolutional Networks 可变形卷积网络论文精读与解析
    ES6 从入门到精通 # 18:使用 Promise 封装 ajax
    Seaborn数据可视化综合应用Basemap和Seaborn在线闯关_头歌实践教学平台
    海量数据处理面试题
    枪出惊龙,众“锁”周之
  • 原文地址:https://blog.csdn.net/m0_58212960/article/details/126449922