CSDB Blog Quick Backup Program - Backup Your BLOG

xiaoxiao2021-03-06  65

The following procedure requires htmlparser.jar. You can download directly from http://umn.dl.sourceforge.net/sourceforge/htmlparser/htmlparser1_5_20040728.zip, http: //htmlparser.sourceForge.net is the home page of HTMLParser. // Copy from here./*************************************************** ******************************************* * $ Header $ * $ Revision $ * $ DATE $ * * ============================================================================================================================================================================================================= ============================ * * CopyRight (C) 2001-2004 XXX Technologies, Ltd. * All Rights reserved. * * CREATED ON 2004-12-3 ************************************************************* ****************************************** /

import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import Java.net.malformedurlexception; import java.net.URL; import java.text.MessageFormat; import java.util.arrayList; import java.util.list;

Import javax.xml.parsers.documentbuilder; import javax.xml.parsers.DocumentBuilderFactory;

import org.htmlparser.Node; import org.htmlparser.Parser; import org.htmlparser.lexer.Page; import org.htmlparser.tags.Div; import org.htmlparser.util.ParserException; import org.w3c.dom.Document; Import org.w3c.dom.element; import org.w3c.dom.nodelist;

/ ** * * @author 斐 (MAILTO: MR_YANFEI & Yahoo.com) * // * * Modify history * $ * / public final class blogbackuptool {private static final string @ p p = "http://blog.9cbs.net /mr_yanfei/Rss.aspx "; private static final String sAVE_PATH =" d: // temp "; private static final String CHANNEL =" channel "; private static final String CHANNEL_ITEM =" item "; private static final String ITEM_TITLE =" title "; private static final String ITEM_LINK =" link "; private static final boolean FILTER = true; class Blog {private String fTitle; private String fLink; public Blog (String title, String link) {fTitle = title; fLink = link;} Public string gettitle () {returnifetle;} public string getLink () { return fLink;}} private Blog [] getBlogs (String rssUrl) {DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance (); factory.setNamespaceAware (true); List result = new ArrayList (); try {URL url = new URL (rssUrl); DocumentBuilder builder = factory.newDocumentBuilder (); Document document = builder.parse (url.openStream ()); Element channel = document.getDocumentElement (); channel = (Element) document.getElementsByTagName (CHANNEL) .item (0);

IF (Channel.Equals ())) {nodelist nodes = channel.getChildNodes (); for (int i = 0; i

Result.replace ('<', '_'); result = result.replace ('>', '_'); result = result.replace ('|', '_'); result = result.replace (' "',' _ '); Return Result;} private void saveblogs (blog [] blogs) throws Exception {string title, link; for (int i = 0; i

IF (file) {Parser Parser = NULL; Try {Parser = New Parser (LINK); (ParserException EX) {Continue;} Page Page = PARSER.GETLEXER (). getPage (); string pageurl = page.geturl ); Node [] Bases = Parser.extractallNodesthatare (Div.class); for (int J = 0; j

转载请注明原文地址:https://www.9cbs.com/read-84912.html

New Post(0)