简单的数据抓取
来源:互联网 发布:python 程序运行时间 编辑:程序博客网 时间:2024/06/05 02:27
import net.sf.json.JSONArray;import net.sf.json.JSONObject;import org.springframework.http.HttpEntity;import org.springframework.http.HttpHeaders;import org.springframework.http.HttpMethod;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.client.RestTemplate;import java.security.Principal;import java.util.*;@Controllerpublic class VideoController { RestTemplate restTemplate = new RestTemplate(); @RequestMapping(value = "/thirdvideo") public String getThirdVideo(Principal principal) { HttpHeaders headers = new HttpHeaders(); headers.set("X-User-Id", "wap_4ee619668421c1524442ccc85c875f2b"); ResponseEntity<String> response = restTemplate.exchange("http://www.baca.co.id/api/v1/News?categoryId=16", HttpMethod.GET, new HttpEntity<String>(headers), String.class); JSONArray results = JSONObject.fromObject(response).getJSONObject("body").getJSONArray("News"); for (Object news : results) { String newsId = JSONObject.fromObject(news.toString()).getString("NewsId"); String title = JSONObject.fromObject(news.toString()).getString("Title"); String media = JSONObject.fromObject(news.toString()).getString("Media"); String sourceLink = JSONObject.fromObject(news.toString()).getString("Url"); String images = JSONObject.fromObject(news.toString()).getJSONArray("ImageGuids").getString(0); Object videoUrl = JSONObject.fromObject(news.toString()).get("Video"); String content = JSONObject.fromObject(videoUrl.toString()).getString("VideoUrl"); } return "redirect:/news/"; }
0 0
- 简单的数据抓取
- java简单的抓取网页数据
- 使用Jsoup 简单抓取页面的数据
- 利用Jsoup解析网页,抓取数据的简单应用
- 利用python中的pyquery库简单的抓取数据
- R语言实现简单的网页数据抓取
- scrapy的简单应用-抓取链家数据
- golang简单的抓取
- 网页数据的抓取
- 抓取csdn的数据
- php 网页数据抓取 简单实例
- 屏幕抓取的简单实现
- 简单的图片抓取demo
- 数据抓取的一些心得
- php页面的数据抓取
- 抓取页面想要的数据
- 数据抓取的艺术(二):数据抓取程序优化
- 数据抓取的艺术(二):数据抓取程序优化
- AOJ 866 飞越原野 【BFS】
- 应用session对象实现登陆
- Ubuntu 16 下配置Faster_rcnn 訓練自己的数据
- Python数据采集之网页解析器
- 几种常用的矩阵范数
- 简单的数据抓取
- MySQL数据库(18)
- Linux--RH134---unit 7 访问网络共享文件系统
- 使用缓冲流读取试题文件,每次显示试题文件中的一道题目。读取到字符“*”时候暂停读取,等待用户从键盘输入答案。用户做完全部题目后,程序给出用户的得分。Test.txt如下:
- 微信公众号支付开发流程备忘
- ajax返回的值被方法外取到
- hadoop伪分布搭建
- git命令-切换分支
- shiro造成dubbo无法注入java.lang.IllegalStateException: ApplicationEventMulticaster not initialized