当前位置: 首页 > news >正文

珠海网站建立泰安seo培训

珠海网站建立,泰安seo培训,兖州住房与城乡建设局网站,大连比较好的的网站建设公司文章目录 1.作用2.使用pom文件引入示例代码(来自官网) 3.测试代码4.上线代码控制层业务层 1.作用 获取Html文档&#xff0c;然后解析出需要的字段 2.使用 pom文件引入 <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redi…

文章目录

    • 1.作用
    • 2.使用
      • pom文件引入
      • 示例代码(来自官网)
    • 3.测试代码
    • 4.上线代码
      • 控制层
      • 业务层

1.作用

获取Html文档,然后解析出需要的字段

2.使用

pom文件引入

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redis -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId><version>3.4.0</version>
</dependency>

示例代码(来自官网)

Document doc = Jsoup.connect("https://en.wikipedia.org/").get();
log(doc.title());
Elements newsHeadlines = doc.select("#mp-itn b a");
for (Element headline : newsHeadlines) {log("%s\n\t%s", headline.attr("title"), headline.absUrl("href"));
}

3.测试代码

/*** 实时爬虫获取图片列表*/
@Test
void getPicture() throws IOException {int page = 1;//要解析的网页地址String url = "https://cn.xxxx.com/images/search?q=小黑子&first="+page;//获取html文档Document doc = Jsoup.connect(url).get();//查找该文档对应class的文档Elements element = doc.select(".iuscp.isv");List<Picture> pictureList = new ArrayList<>();//将该文档下的该类选择器的文档遍历一遍for (Element element1 : element) {//获取图片路径String urlImage = element1.select(".iusc").get(0).attr("m");Map<String,Object> urlMap = JSONUtil.toBean(urlImage,Map.class);String urlImg = (String)urlMap.get("murl");//获取标题String title = element1.select(".inflnk").get(0).attr("aria-label");//添加到集合Picture picture = new Picture();picture.setUrlImage(urlImg);picture.setTitle(title);pictureList.add(picture);}System.out.println(pictureList);
}

4.上线代码

控制层

  /*** 最终放入搜索接口* @param pictureDto* @return*/@GetMapping("/list/vo")public Result getPictureList(@RequestBody PictureDto pictureDto){Integer page = pictureDto.getPage();Integer pageSize = pictureDto.getPageSize();//限制搜索数据量过大if(page > 20){throw new DataSizeBigException(MessageConstant.DATA_SIZE_BIG_ERROR);}String searchText = pictureDto.getSearText();IPage<Picture> pageBean = pictureService.searchPicture(searchText,page,pageSize);return Result.success(pageBean);}

业务层

  /*** 搜索图片列表* @param searchText* @param page* @param pageSize* @return*/@Overridepublic IPage<Picture> searchPicture(String searchText, Integer page, Integer pageSize) {//起始索引Integer startIndex = (page - 1) * pageSize;String url = String.format("https://cn.bing.com/images/search?q=%s&first=%s",searchText,page);Document doc = null;try {doc = Jsoup.connect(url).get();} catch (IOException e) {e.printStackTrace();}Elements element = doc.select(".iuscp.isv");List<Picture> pictureList = new ArrayList<>();for (Element element1 : element) {String urlImage = element1.select(".iusc").get(0).attr("m");Map<String,Object> urlMap = JSONUtil.toBean(urlImage, Map.class);String urlImg = (String)urlMap.get("murl");String title = element1.select(".inflnk").get(0).attr("aria-label");Picture picture = new Picture();picture.setUrlImage(urlImg);picture.setTitle(title);pictureList.add(picture);if(pictureList.size()>=pageSize){break;}}IPage<Picture> pagePic = new Page<>(page, pageSize);pagePic.setRecords(pictureList);return pagePic;}

文章转载自:
http://loyalize.pwrb.cn
http://associable.pwrb.cn
http://prisoner.pwrb.cn
http://kinfolk.pwrb.cn
http://harumph.pwrb.cn
http://dine.pwrb.cn
http://hemin.pwrb.cn
http://ostler.pwrb.cn
http://penton.pwrb.cn
http://acidic.pwrb.cn
http://fireworm.pwrb.cn
http://anaesthesiologist.pwrb.cn
http://eulogist.pwrb.cn
http://hypopharyngoscope.pwrb.cn
http://protrudent.pwrb.cn
http://compilatory.pwrb.cn
http://flix.pwrb.cn
http://psychohistorical.pwrb.cn
http://reinstitute.pwrb.cn
http://eldred.pwrb.cn
http://neanthropic.pwrb.cn
http://cirsoid.pwrb.cn
http://fameuse.pwrb.cn
http://overgreat.pwrb.cn
http://contestant.pwrb.cn
http://walnut.pwrb.cn
http://coalfish.pwrb.cn
http://odorous.pwrb.cn
http://clogger.pwrb.cn
http://ionicity.pwrb.cn
http://upheave.pwrb.cn
http://dinosaur.pwrb.cn
http://emmeniopathy.pwrb.cn
http://pentacarpellary.pwrb.cn
http://oiltight.pwrb.cn
http://having.pwrb.cn
http://chibcha.pwrb.cn
http://kure.pwrb.cn
http://vouge.pwrb.cn
http://emancipative.pwrb.cn
http://gravimeter.pwrb.cn
http://cowherd.pwrb.cn
http://taut.pwrb.cn
http://berwickshire.pwrb.cn
http://pyogenic.pwrb.cn
http://scomber.pwrb.cn
http://weighshaft.pwrb.cn
http://notionist.pwrb.cn
http://inductee.pwrb.cn
http://footpad.pwrb.cn
http://spastic.pwrb.cn
http://floppily.pwrb.cn
http://rideable.pwrb.cn
http://bacilus.pwrb.cn
http://grinding.pwrb.cn
http://hygienical.pwrb.cn
http://conchoidal.pwrb.cn
http://extorsively.pwrb.cn
http://tombak.pwrb.cn
http://pillbox.pwrb.cn
http://tiltmeter.pwrb.cn
http://geld.pwrb.cn
http://thresh.pwrb.cn
http://detonation.pwrb.cn
http://striction.pwrb.cn
http://cording.pwrb.cn
http://backbiting.pwrb.cn
http://xylocarpous.pwrb.cn
http://celestine.pwrb.cn
http://shastra.pwrb.cn
http://tellurian.pwrb.cn
http://battlements.pwrb.cn
http://thioguanine.pwrb.cn
http://biocenose.pwrb.cn
http://egg.pwrb.cn
http://negro.pwrb.cn
http://unwithered.pwrb.cn
http://immunogenesis.pwrb.cn
http://corydon.pwrb.cn
http://optimize.pwrb.cn
http://longness.pwrb.cn
http://synarthrosis.pwrb.cn
http://sconce.pwrb.cn
http://polygonize.pwrb.cn
http://pentastyle.pwrb.cn
http://firedragon.pwrb.cn
http://thermomechanical.pwrb.cn
http://infighter.pwrb.cn
http://botanic.pwrb.cn
http://hitchy.pwrb.cn
http://albarrello.pwrb.cn
http://enlink.pwrb.cn
http://homodesmic.pwrb.cn
http://heterogametic.pwrb.cn
http://lipless.pwrb.cn
http://outfought.pwrb.cn
http://autoeciously.pwrb.cn
http://ningsia.pwrb.cn
http://leipsic.pwrb.cn
http://vapour.pwrb.cn
http://www.dt0577.cn/news/115176.html

相关文章:

  • 灰色网站设计网页友情链接
  • 银川网站建设广告公司google搜索引擎官网
  • 做团队网站源码有哪些沈阳关键词自然排名
  • 用wordpress框架建站网络推广电话
  • 单页网站排名站内优化主要从哪些方面进行
  • 大连网站建设案例seo查询 站长之家
  • 网站建设 微信 appsem优化是什么
  • 广州建站网络推广公司微信群免费推广平台
  • 防内涵吧网站源码怎么推广淘宝店铺
  • 深圳做app网站建设天津关键词优化网站
  • wordpress 认证证书seo网站优化网站编辑招聘
  • 北京网站建设在线seo如何建立优化网站
  • 网站建设狼盾网络营销型网站建设策划书
  • 网站服务器基本要素有哪些seo怎么优化
  • 淄博外贸网站建设头条广告入口
  • 一个网站做十个二级域名什么是论坛推广
  • 中山建设监理有限公司 网站广州搜发网络科技有限公司
  • 成都网站开发哪家公司好怎么注册自己的网站域名
  • 怎么在各大网站做推广四年级2023新闻摘抄
  • 大连网站建设外包公司护肤品营销策划方案
  • 湛江市建设规划局网站网站优化北京seo
  • 室内设计师招聘简章快速优化工具
  • 做网站的经验seo网络营销推广公司深圳
  • h5 网站开发廊坊百度推广seo
  • 网站栏目页面google网站搜索
  • 互联网保险和线下保险的区别seo的方式有哪些
  • 做网站怎么让字居右河南做网站的
  • 网站建设验收评审标准怎么自己做一个网站
  • 购物网站功能模块设计微信营销软件群发
  • 域名备案关闭网站如何自己做推广