6
来源:互联网 发布:雅马哈popcom软件下载 编辑:程序博客网 时间:2024/04/28 09:57
try {
DocumentBuilderFactory dbFactory =DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new URL("http://api.flickr.com/services/rest/?method=flickr.photos.search&per_page=10&api_key=a7fb01d9f23e2664a0086bbee84e692a&sort=relevance&text="+j.replace(" ", "+")).openStream());
//optional, but recommended
//read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("photo");
int count=1;
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() ==Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String x=eElement.getAttribute("server")+";"+eElement.getAttribute("farm")+";"+eElement.getAttribute("id")+";"+eElement.getAttribute("owner")+";"+eElement.getAttribute("secret");
String fid="p"+count;
sb.append("<form id='"+fid+"' method='post' action='http://127.0.0.1:8080/Task8Genie/makewish_start.do'><input type=hidden name=h_cat value="+k+"><input type=hidden name=wish value='"+j+"'><input type=hidden name=hid value="+x+"><a href='#' onclick=\"document.getElementById('"+fid+"').submit();return false;\"><img src=http://farm"+eElement.getAttribute("farm")+".staticflickr.com/"+eElement.getAttribute("server")+"//"+eElement.getAttribute("id")+"_"+eElement.getAttribute("secret")+"_m.jpg></a></form><br>");
count++;
}
}
return"<html> " + "<title>" + "Hello Jersey" +"</title>"
+ "<body style='background-color:#EEEEEE;'><h2>Choose a Image for Wish Topic!</h2>" +sb.toString()+"</body>" + "</html> ";
}
0 0
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 云计算”
- C语言开发基础知识
- 几个常用的Javascript字符串处理函数 spilt(),join(),substring()和indexof()
- VC2010 MFC中实现printf调试功能,即MFC程序利用控制台输出调试信息
- 爬虫相关(1)--- 如何使用java来获取HTML源码
- 6
- 心情低落的时候看看这个
- Quartz定时任务
- Root权限
- boost库之shared_ptr
- iOS develop:写于开始
- jQueue 动态设置form表单的action属性的值和方法
- Root就是手机的神经中枢
- usaco 2004 Open Cube Stacking 堆方块 题解