• R/O
  • SSH
  • HTTPS

提交

标签

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

作業部屋の使い方を試しています。


Commit MetaInfo

修订版146 (tree)
时间2018-03-04 15:32:35
作者tuna_p

Log Message

最新化

更改概述

差异

--- branches/b4/webScraping/src/webScraping/core/HtmlParser.java (revision 145)
+++ branches/b4/webScraping/src/webScraping/core/HtmlParser.java (revision 146)
@@ -51,13 +51,13 @@
5151 /* ---------------------------------------------------------------------- *
5252 * コンストラクタ
5353 * ---------------------------------------------------------------------- */
54- public HtmlParser(URL UrlAdress) {
54+ public HtmlParser(URL UrlAdress) throws UnknownHostException {
5555 DebugProcess.debuglog_set();
5656 this.url = UrlAdress;
5757 getPageData();
5858 }
5959
60- public HtmlParser(String UrlAdress) {
60+ public HtmlParser(String UrlAdress) throws UnknownHostException {
6161 DebugProcess.debuglog_set();
6262 try {
6363 url = new URL(UrlAdress);
@@ -83,7 +83,7 @@
8383 /* ---------------------------------------------------------------------- *
8484 * Setter
8585 * ---------------------------------------------------------------------- */
86- public void seturl(URL UrlAdress) {
86+ public void seturl(URL UrlAdress) throws UnknownHostException {
8787 this.url = UrlAdress;
8888 getPageData();
8989 }
@@ -91,7 +91,7 @@
9191 /* ---------------------------------------------------------------------- *
9292 * メソッド
9393 * ---------------------------------------------------------------------- */
94- public void seturl(String UrlAdress) {
94+ public void seturl(String UrlAdress) throws UnknownHostException {
9595 try {
9696 url = new URL(UrlAdress);
9797 getPageData();
@@ -223,7 +223,7 @@
223223 /**
224224 * インターネット接続.
225225 */
226- private void getPageData() {
226+ private void getPageData() throws UnknownHostException {
227227 HttpURLConnection con = null;
228228 try {
229229 con = (HttpURLConnection)url.openConnection();
@@ -237,9 +237,11 @@
237237 }
238238 pageData = sb.toString();
239239
240+ } catch(UnknownHostException ex) {
241+ throw ex;
240242 } catch(FileNotFoundException ex) {
241243 pageData = null;
242- } catch (IOException ex) {
244+ } catch(IOException ex) {
243245 Logger.getLogger(HtmlParser.class.getName()).log(Level.SEVERE, null, ex);
244246 } finally {
245247 if(con != null) {
--- branches/b4/webScraping/src/webScraping/core/Scraping.java (revision 145)
+++ branches/b4/webScraping/src/webScraping/core/Scraping.java (revision 146)
@@ -22,8 +22,7 @@
2222 package webScraping.core;
2323
2424 import java.net.URL;
25-import webScraping.core.HtmlParser;
26-import webScraping.core.SearchData;
25+import java.net.UnknownHostException;
2726
2827 /**
2928 *
@@ -38,8 +37,9 @@
3837 * HTML解析.
3938 * @param url
4039 * @return
40+ * @throws java.net.UnknownHostException
4141 */
42- public String[] getResult(URL url) {
42+ public String[] getResult(URL url) throws UnknownHostException {
4343
4444 HtmlParser par = new HtmlParser(url);
4545
--- branches/b4/webScraping/src/webScraping/utility/HtmlSearch.java (revision 145)
+++ branches/b4/webScraping/src/webScraping/utility/HtmlSearch.java (revision 146)
@@ -30,9 +30,11 @@
3030 import java.net.URI;
3131 import java.net.URISyntaxException;
3232 import java.net.URL;
33+import java.net.UnknownHostException;
3334 import java.util.logging.Level;
3435 import java.util.logging.Logger;
3536 import javax.swing.JFileChooser;
37+import javax.swing.JOptionPane;
3638 import javax.swing.filechooser.FileFilter;
3739 import javax.swing.filechooser.FileNameExtensionFilter;
3840 import javax.swing.table.DefaultTableModel;
@@ -396,7 +398,12 @@
396398 */
397399 void Search_execution_old() {
398400 jTxtRtn.setText(null);
399- HtmlParser par = new HtmlParser(jTxtUrl.getText());
401+ HtmlParser par = null;
402+ try {
403+ par = new HtmlParser(jTxtUrl.getText());
404+ } catch (UnknownHostException ex) {
405+ Logger.getLogger(HtmlSearch.class.getName()).log(Level.SEVERE, null, ex);
406+ }
400407
401408 // データ無し(404)判定
402409 String strdata = par.getStringPageData();
@@ -446,7 +453,13 @@
446453 }
447454
448455 // HTML検索
449- String[] result = scrap.getResult(url);
456+ String[] result;
457+ try {
458+ result = scrap.getResult(url);
459+ } catch (UnknownHostException ex) {
460+ JOptionPane.showMessageDialog(this, "URLを確認してください");
461+ return;
462+ }
450463
451464 // 検索結果
452465 if(result == null) {