日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

W3C api 抓取

發布時間:2025/1/21 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 W3C api 抓取 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

存檔

W3CIDLFetcher

package canghailan.w3c;import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element;import java.io.BufferedWriter; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date;/*** @author canghailan 2011-12-26 14:54*/ public class W3CIDLFetcher {private static final int TIMEOUT = 60 * 1000; // 1minprivate static final String[] CSS_URLS = {"http://dev.w3.org/csswg/cssom/","http://dev.w3.org/csswg/cssom-view/"};private static final String[] DOM_URLS = {"http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html","http://www.w3.org/TR/DOM-Level-3-Events/"};private static final String[] HTML_URLS = {"http://www.w3.org/TR/html5/Overview.html",};public static String[] fetchAll() throws IOException, URISyntaxException {Path home = Paths.get(W3CIDLFetcher.class.getProtectionDomain().getCodeSource().getLocation().toURI());String timestamp = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());Path cssIdl = home.resolve("css" + timestamp + ".idl");Path domIdl = home.resolve("dom" + timestamp + ".idl");Path htmlIdl = home.resolve("html" + timestamp + ".idl");fetch(Arrays.asList(CSS_URLS), cssIdl.toString());fetch(Arrays.asList(DOM_URLS), domIdl.toString());fetch(Arrays.asList(HTML_URLS), htmlIdl.toString());return new String[]{cssIdl.toString(), domIdl.toString(), htmlIdl.toString()};}public static void fetch(Iterable<String> urls, String path) throws IOException {for (String url : urls) {fetch(url, path);}}public static void fetch(String url, String path) throws IOException {System.out.println("fetch idl: " + url + " -> " + path);Document doc = Jsoup.connect(url).timeout(TIMEOUT).get();BufferedWriter writer = Files.newBufferedWriter(Paths.get(path), Charset.forName("UTF-8"),StandardOpenOption.WRITE,StandardOpenOption.CREATE,StandardOpenOption.APPEND);for (Element idl : doc.select("pre.idl")) {writer.write(idl.text());writer.write("\n\n");}writer.flush();writer.close();}public static void main(String[] args) throws IOException, URISyntaxException {fetchAll();}}

WebIDLGrammarDownloader

package canghailan.webidl;import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements;import java.io.BufferedWriter; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption;/*** @author canghailan 2011-12-26 19:39*/ public class WebIDLGrammarDownloader {private static final int TIMEOUT = 60 * 1000; // 1minpublic static void download() throws IOException, URISyntaxException {Document doc = Jsoup.connect("http://www.w3.org/TR/WebIDL/").timeout(TIMEOUT).get();Elements grammars = doc.select("#appendices .grammar");Path home = Paths.get(WebIDLGrammarDownloader.class.getProtectionDomain().getCodeSource().getLocation().toURI());Path webIdlGrammar = home.resolve("web-idl.g");BufferedWriter writer = Files.newBufferedWriter(webIdlGrammar, Charset.forName("UTF-8"),StandardOpenOption.WRITE,StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING);for (Element grammar : grammars) {for (Element tr : grammar.select("tr")) {writer.write(tr.text());writer.write('\n');}}writer.flush();writer.close();}public static void main(String[] args) throws IOException, URISyntaxException {download();} }

w3c-api:?https://code.google.com/p/es-operating-system/

轉載于:https://my.oschina.net/canghailan/blog/38431

總結

以上是生活随笔為你收集整理的W3C api 抓取的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。