CMS 内容页sitemap.xml 获取
来源:互联网 发布:js null===undefined 编辑:程序博客网 时间:2024/04/25 06:47
package com.tidemedia.cutv;
import java.io.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tidemedia.cms.base.MessageException;
import tidemedia.cms.base.TableUtil;
import tidemedia.cms.system.Channel;
import tidemedia.cms.system.CmsCache;
import tidemedia.cms.system.Document;
import tidemedia.cms.system.Site;
import tidemedia.cms.util.FileUtil;
import tidemedia.cms.util.Util;
public class ExportSiteMapXMLDate {
public ExportSiteMapXMLDate() {
}
public void emportXml() throws MessageException, SQLException, JSONException {
// 新闻,城市,科教,影视,生活,评论,娱乐,房产,旅游
String content = "[{\"channelid\":\"169,170\"},{\"channelid\":\"8800\"}]";
JSONArray ja = new JSONArray(content);
for(int i=0 ;i<ja.length();i++){
JSONObject jb =ja.getJSONObject(i);
String channelid = jb.getString("channelid");
emportXml_(channelid);
}
}
public void emportXml_(String channelids) throws MessageException,
SQLException {
String channelid[] = channelids.split(",");
Channel channel = CmsCache.getChannel(Util.parseInt(channelid[0]));
System.out.println("siteid="+channel.getSite().getSiteFolder());
long t1 = System.currentTimeMillis();//获得当前时间毫秒
String xmlfilepath = channel.getSite().getSiteFolder();
if (!xmlfilepath.endsWith("/")) {
xmlfilepath = xmlfilepath + "/";
}
if (!xmlfilepath.startsWith("/")) {
xmlfilepath = "/" + xmlfilepath;
}
String xmlfile = xmlfilepath + "test_sitemap.xml";
String strxml = "";
try {
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n").toString();
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"<sitemapindex>").toString();
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"<sitemap>").toString();
long now = System.currentTimeMillis(); // 现在经过的毫秒数
long time = now / 1000;// 现在经过的秒数
long time2 = time - 2 * 24 * 60 * 60;// 少两天的天数
/**
* 内容页循环
*/
for (int i = 0; i < channelid.length; i++) {
TableUtil tu = new TableUtil();
//Channel ch = CmsCache.getChannel(channelid[i]);
Channel ch = CmsCache.getChannel(Util.parseInt(channelid[i]));
//System.out.println("time2--->" + time2);
String sql = "select GlobalID from "
+ ch.getTableName()
+ " where Status=1 and ChannelCode like '"+ch.getChannelCode()+"%' and CreateDate>"
+ time2;
System.out.println("sql----->" + sql);
ResultSet rs = tu.executeQuery(sql);
Document doc = null;
while (rs.next()) {
int globalid = rs.getInt("GlobalID");
doc = new Document(globalid);
System.out.println("globalid--->"+globalid);
strxml = (new StringBuilder(String.valueOf(strxml)))
.append("<loc>").append(doc.getHttpHref()).append(
"</loc>").toString();
}
System.out.println("loc--->" + doc.getHttpHref());
tu.closeRs(rs);
}
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"</sitemap>").toString();
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"</sitemapindex>").toString();
PrintWriter out1 = new PrintWriter(new BufferedWriter(
new FileWriter(xmlfile)));
out1.write(strxml);
out1.close();
int SiteId = channel.getSite().getId();
Site site = CmsCache.getSite(SiteId);
String SiteFolder = site.getSiteFolder();
FileUtil fileutil = new FileUtil();
fileutil
.PublishFiles("test_sitemap.xml", "/", SiteFolder, 13, site);
} catch (IOException e) {
e.printStackTrace();
}
File xml_file = new File(xmlfile);
int filesize = (int) (xml_file.length() / 1024L);
long t2 = System.currentTimeMillis();
long lasttime = t2 - t1;
System.out.println("---------end-----");
}
}
import java.io.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tidemedia.cms.base.MessageException;
import tidemedia.cms.base.TableUtil;
import tidemedia.cms.system.Channel;
import tidemedia.cms.system.CmsCache;
import tidemedia.cms.system.Document;
import tidemedia.cms.system.Site;
import tidemedia.cms.util.FileUtil;
import tidemedia.cms.util.Util;
public class ExportSiteMapXMLDate {
public ExportSiteMapXMLDate() {
}
public void emportXml() throws MessageException, SQLException, JSONException {
// 新闻,城市,科教,影视,生活,评论,娱乐,房产,旅游
String content = "[{\"channelid\":\"169,170\"},{\"channelid\":\"8800\"}]";
JSONArray ja = new JSONArray(content);
for(int i=0 ;i<ja.length();i++){
JSONObject jb =ja.getJSONObject(i);
String channelid = jb.getString("channelid");
emportXml_(channelid);
}
}
public void emportXml_(String channelids) throws MessageException,
SQLException {
String channelid[] = channelids.split(",");
Channel channel = CmsCache.getChannel(Util.parseInt(channelid[0]));
System.out.println("siteid="+channel.getSite().getSiteFolder());
long t1 = System.currentTimeMillis();//获得当前时间毫秒
String xmlfilepath = channel.getSite().getSiteFolder();
if (!xmlfilepath.endsWith("/")) {
xmlfilepath = xmlfilepath + "/";
}
if (!xmlfilepath.startsWith("/")) {
xmlfilepath = "/" + xmlfilepath;
}
String xmlfile = xmlfilepath + "test_sitemap.xml";
String strxml = "";
try {
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n").toString();
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"<sitemapindex>").toString();
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"<sitemap>").toString();
long now = System.currentTimeMillis(); // 现在经过的毫秒数
long time = now / 1000;// 现在经过的秒数
long time2 = time - 2 * 24 * 60 * 60;// 少两天的天数
/**
* 内容页循环
*/
for (int i = 0; i < channelid.length; i++) {
TableUtil tu = new TableUtil();
//Channel ch = CmsCache.getChannel(channelid[i]);
Channel ch = CmsCache.getChannel(Util.parseInt(channelid[i]));
//System.out.println("time2--->" + time2);
String sql = "select GlobalID from "
+ ch.getTableName()
+ " where Status=1 and ChannelCode like '"+ch.getChannelCode()+"%' and CreateDate>"
+ time2;
System.out.println("sql----->" + sql);
ResultSet rs = tu.executeQuery(sql);
Document doc = null;
while (rs.next()) {
int globalid = rs.getInt("GlobalID");
doc = new Document(globalid);
System.out.println("globalid--->"+globalid);
strxml = (new StringBuilder(String.valueOf(strxml)))
.append("<loc>").append(doc.getHttpHref()).append(
"</loc>").toString();
}
System.out.println("loc--->" + doc.getHttpHref());
tu.closeRs(rs);
}
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"</sitemap>").toString();
strxml = (new StringBuilder(String.valueOf(strxml))).append(
"</sitemapindex>").toString();
PrintWriter out1 = new PrintWriter(new BufferedWriter(
new FileWriter(xmlfile)));
out1.write(strxml);
out1.close();
int SiteId = channel.getSite().getId();
Site site = CmsCache.getSite(SiteId);
String SiteFolder = site.getSiteFolder();
FileUtil fileutil = new FileUtil();
fileutil
.PublishFiles("test_sitemap.xml", "/", SiteFolder, 13, site);
} catch (IOException e) {
e.printStackTrace();
}
File xml_file = new File(xmlfile);
int filesize = (int) (xml_file.length() / 1024L);
long t2 = System.currentTimeMillis();
long lasttime = t2 - t1;
System.out.println("---------end-----");
}
}
- CMS 内容页sitemap.xml 获取
- sitemap.xml
- 如何让帝国CMS如何自动生成sitemap.xml网站地图文件
- 动态获取织梦CMS最新更新 利于收录的SiteMap.php文件
- JS获取XML内容!
- JS获取XML内容
- 获取XML文件内容
- 获取XML文件内容
- XML Sitemap 相关问题
- sitemap xml 协议
- XML Sitemap 相关问题
- XML Sitemap 相关问题
- sitemap.xml的写法
- Laravel 4 Sitemap--动手写Laravel CMS
- JAVASCRIPT 获取 XML 文件内容
- PHP如何获取XML内容?
- sax 获取xml所有内容
- SAX方式获取XML内容
- Draw2D技术
- 计算机经典书籍推荐
- OpenCV基本环境搭建(Windows 7 + x86/x64 )
- 桥接模式(Bridge Pattern)
- oracle技术之自定义数组及应用
- CMS 内容页sitemap.xml 获取
- 技术28
- android APK升级
- 源IP选择
- Mini USB
- 自然图像抠图/视频抠像技术发展情况梳理
- 为什么要测量扭矩?
- ubuntu12.04 下eclipse快捷键(alt + \)自动补全 失效
- 查看数据库阻塞