busgogo 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +9 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +45 -0
- data/Output.txt +1 -0
- data/Procfile +1 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/Structure.txt +542 -0
- data/bin/executable.rb +26 -0
- data/busgogo.gemspec +16 -0
- data/lib/busgogo.rb +78 -0
- data/spec/minitest.rb +45 -0
- metadata +34 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa9966741d7f0e0ffcaf536e0ab25cc2145bfdb7
|
4
|
+
data.tar.gz: 3b2b7936bc095c2b1b6bfb4eef3e50006b5e2668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f950b8bcc0d5b11c371da8ba9b66c248cc0c5c204c8e9cc70e076b7f9e07a8792c8084200550f69d233492763f9f99196f2ac9ba10c64f9cdc17b037c53c50bf
|
7
|
+
data.tar.gz: 6e7390e9c6452d58640bf79f2fb6a89865fdbab0a408d08f8e6c731a472fce2791e23f2816b7c2eb4c9a6395ee75aedd33c837a96ca58d3654184bc88fdcfdc0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
busgogo (0.2.1)
|
5
|
+
mechanize
|
6
|
+
nokogiri (>= 1.6.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
domain_name (0.5.22)
|
12
|
+
unf (>= 0.0.5, < 1.0.0)
|
13
|
+
http-cookie (1.0.2)
|
14
|
+
domain_name (~> 0.5)
|
15
|
+
mechanize (2.7.3)
|
16
|
+
domain_name (~> 0.5, >= 0.5.1)
|
17
|
+
http-cookie (~> 1.0)
|
18
|
+
mime-types (~> 2.0)
|
19
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
20
|
+
net-http-persistent (~> 2.5, >= 2.5.2)
|
21
|
+
nokogiri (~> 1.4)
|
22
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
23
|
+
webrobots (>= 0.0.9, < 0.2)
|
24
|
+
mime-types (2.4.3)
|
25
|
+
mini_portile (0.6.1)
|
26
|
+
net-http-digest_auth (1.4)
|
27
|
+
net-http-persistent (2.9.4)
|
28
|
+
nokogiri (1.6.4.1)
|
29
|
+
mini_portile (~> 0.6.0)
|
30
|
+
nokogiri (1.6.4.1-java)
|
31
|
+
ntlm-http (0.1.1)
|
32
|
+
rake (10.3.2)
|
33
|
+
unf (0.1.4)
|
34
|
+
unf_ext
|
35
|
+
unf (0.1.4-java)
|
36
|
+
unf_ext (0.0.6)
|
37
|
+
webrobots (0.1.1)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
java
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
busgogo!
|
45
|
+
rake
|
data/Output.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
["**************************************", "總公司", "(03)5225151~7", "(03)5257450", "新竹市民族路16-1號", "**************************************", "房屋、土地招租、車廂廣告洽談", "(03)5225151#236、222", "", "", "**************************************", "客服專線", "0800-035800", "", "", "**************************************", "永順旅行社", "(03)5265150~1,(03)5236320", "(03)5265152", "新竹市民族路16號2樓", "**************************************", "遊覽車租賃專線", "(03)5224258", "", "", "**************************************", "新竹客運駕訓班", "(03)5290134", "(03)5201785", "新竹市明湖路484號", "**************************************", "報名專線", "(03)5201127", "", "", "**************************************", "修車廠(湖口廠區)", "(03)5981120", "", "新竹縣湖口鄉鳳山村中華路13號", "**************************************", "車輛檢驗場", "(03)5977249", "", "新竹縣湖口鄉鳳山村中華路13號", "**************************************", "修車廠(牛埔廠區)", "(03)5387500", "(03)5387155", "新竹市牛埔路200號", "**************************************", "修車廠-材料課", "(03)5387157", "", "新竹市牛埔路200號", "**************************************", "新竹總站", "(03)5259599", "(03)5259499", "新竹市中華路二段471號", "**************************************", "新竹總站-新竹北站", "(03)5218841", "", "新竹市中華路二段415號", "**************************************", "新竹總站-清大售票窗口", "(03)5737836", "", "新竹市光復路二段清大售票亭", "**************************************", "市區公車總站", "(03)5268599", "(03)5280500", "新竹市民族路16-1號", "**************************************", "市區公車-民族路站", "(03)5225151#125", "", "新竹市民族路16號", "**************************************", "新竹保養場", "(03)5387159", "", "新竹市牛埔路200號", "**************************************", "產業工會", "(03)5230399", "", "新竹市中華路二段471號2樓", "**************************************", "湖口站", "(03)5992158", "", "新竹縣湖口鄉中山路二段90號", "**************************************", "**************************************", "竹東總站", "(03)5962018", "(03)5963244", "新竹縣竹東鎮東寧路三段135號", "**************************************", "下公館站", "(03)5962347", "", "新竹縣竹東鎮東寧路一段1號", "**************************************", "竹東檢修班", "(03)5951648", "", "新竹縣竹東鎮東寧路一段1號", "**************************************", "**************************************", "關西總站", "(03)5872001", "(03)5872022", "新竹縣關西鎮中興路17號", "**************************************", "關西檢修班", "(03)5870913", "", "新竹縣關西鎮中興路17號", "**************************************", "新埔站", "(03)5882014", "", "新竹縣新埔鎮中正路221號", "**************************************", "**************************************", "中壢總站", "(03)4258812", "(03)4253121", "桃園縣中壢市建國路105號", "**************************************", "中壢北站", "(03)4253122", "", "桃園縣中壢市元化路2-36號", "**************************************", "中壢檢修班", "(03)4226198", "", "桃園縣中壢市中和路23號", "**************************************", "龍潭站", "(03)4792007", "", "桃園縣龍潭鄉北龍路13號", "**************************************", "楊梅站", "(03)4782412", "(03)4884756", "桃園縣楊梅鎮楊新北路3號", "**************************************", "楊梅保養場", "(03)4780311", "(03)4851256", "桃園縣楊梅鎮楊新北路3號", "**************************************", "**************************************", "苗栗總站", "(037)277981~3", "(037)278701", "苗栗縣苗栗市為公路8號", "**************************************", "苗栗總站-大湖駐在站", "(037)991017", "", "苗栗縣大湖鄉信義路15-1號", "**************************************", "苗栗保養場", "(037)263614", "(037)262460", "苗栗縣苗栗市中華路底台肥停車場", "**************************************", "**************************************", "新竹總站", "(03)5259599", "(03)5259499", "新竹市中華路二段471號", "**************************************", "新竹總站-清大售票窗口", "(03)5737836", "", "新竹市光復路二段清大售票亭", "**************************************", "桃園地區_楊梅站", "(03)4782412", "(03)4884756", "桃園縣楊梅鎮楊新北路3號", "**************************************", "**************************************", "新竹總站", "(03)5259599", "(03)5259499", "新竹市中華路二段471號", "**************************************", "新竹總站-新竹北站", "(03)5218841", "", "新竹市中華路二段415號", "**************************************", "新竹地區_湖口站", "(03)5992158", "", "新竹縣湖口鄉中山路二段90號", "**************************************", "竹東地區_竹東總站", "(03)5962018", "(03)5963244", "新竹縣竹東鎮東寧路三段135號", "**************************************", "竹東地區_下公館站", "(03)5962347", "", "新竹縣竹東鎮東寧路一段1號", "**************************************", "關西地區_關西總站", "(03)5872001", "(03)5872022", "新竹縣關西鎮中興路17號", "**************************************", "關西地區_新埔站", "(03)5882014", "", "新竹縣新埔鎮中正路221號", "**************************************", "桃園地區_中壢總站", "(03)4258812", "(03)4253121", "桃園縣中壢市建國路105號", "**************************************", "桃園地區_中壢北站", "(03)4253122", "", "桃園縣中壢市元化路2-36號", "**************************************", "龍潭站", "(03)4792007", "", "桃園縣龍潭鄉北龍路13號", "**************************************", "桃園地區_楊梅站", "(03)4782412", "(03)4884756", "桃園縣楊梅鎮楊新北路3號", "**************************************", "苗栗地區_苗栗總站", "(037)277981~3", "(037)278701", "苗栗縣苗栗市為公路8號", "**************************************", "苗栗總站-大湖駐在站", "(037)991017", "", "苗栗縣大湖鄉信義路15-1號", "**************************************", "**************************************", "新竹地區_市區公車站", "(03)5268599", "(03)5280500", "新竹市民族路16-1號", "**************************************", "新竹地區_民族路站", "(03)5225151#125", "", "新竹市民族路16號", "**************************************", "**************************************", "桃園地區_楊梅站", "(03)4782412", "(03)4884756", "桃園縣楊梅鎮楊新北路3號", "**************************************"]
|
data/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
##BusGoGo
|
2
|
+
##( Week4 Homework )
|
3
|
+
|
4
|
+
|
5
|
+
###Description ( Hsinzhu Bus Website )
|
6
|
+
|
7
|
+
We use *Hsinzhu Bus Website* because we often take hsinzhu bus to somewhere.
|
8
|
+
Everytime we are heading for somewhere, we go to their website(http://www.hcbus.com.tw/) to get information about their service station, time, and route.
|
9
|
+
Therefore, we think it will be convenience for us to use web scraper to get specific information we want.
|
10
|
+
|
11
|
+
By the way, this website dosen't provide API and need not log in.
|
12
|
+
|
13
|
+
###Files
|
14
|
+
|
15
|
+
1) Class file : busgogo.rb <br/>
|
16
|
+
2) Application file : executable.rb <br/>
|
17
|
+
3) Gemfile : Gemfile<br/>
|
18
|
+
|
19
|
+
###Example Code
|
20
|
+
|
21
|
+
Usage : ruby executable.rb [number]
|
22
|
+
|
23
|
+
1) ruby executable.rb [number] <br/>
|
24
|
+
2) ruby executable.rb 1 <br/>
|
25
|
+
Save HsinZhu Bus Website structure into a file (Structure.txt) <br/>
|
26
|
+
3) ruby executable.rb 2 <br/>
|
27
|
+
Show HsinZhu Bus Station. <br/>
|
28
|
+
4) ruby executable.rb 3 <br/>
|
29
|
+
Get bus stataion information in detail. <br/>
|
30
|
+
5) ruby executable.rb 4 <br/>
|
31
|
+
Get file (bus stataion information)bus(Output.txt).
|
32
|
+
###Authors
|
33
|
+
|
34
|
+
Mavis Cheng (Cheng SyunWei), Yen Wei ,Wu ChiaChun
|
35
|
+
|
36
|
+
### For Authors
|
37
|
+
|
38
|
+
DownLoad
|
39
|
+
SSH : git clone git@github.com:mavischeng/BusGoGo.git
|
data/Rakefile
ADDED
data/Structure.txt
ADDED
@@ -0,0 +1,542 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5
|
+
<title>新竹客運</title>
|
6
|
+
<style type="text/css">
|
7
|
+
<!--
|
8
|
+
body {
|
9
|
+
background-image: url(images/2-1.gif);
|
10
|
+
margin-left: 0px;
|
11
|
+
margin-top: 0px;
|
12
|
+
}
|
13
|
+
-->
|
14
|
+
</style>
|
15
|
+
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
|
16
|
+
<script type="text/javascript">
|
17
|
+
<!--
|
18
|
+
function MM_swapImgRestore() { //v3.0
|
19
|
+
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
|
20
|
+
}
|
21
|
+
function MM_preloadImages() { //v3.0
|
22
|
+
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
|
23
|
+
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
|
24
|
+
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
|
25
|
+
}
|
26
|
+
|
27
|
+
function MM_findObj(n, d) { //v4.01
|
28
|
+
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
|
29
|
+
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
|
30
|
+
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
|
31
|
+
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
|
32
|
+
if(!x && d.getElementById) x=d.getElementById(n); return x;
|
33
|
+
}
|
34
|
+
|
35
|
+
function MM_swapImage() { //v3.0
|
36
|
+
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
|
37
|
+
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
|
38
|
+
}
|
39
|
+
//-->
|
40
|
+
</script>
|
41
|
+
<link href="css/yafen-style.css" rel="stylesheet" type="text/css">
|
42
|
+
<link href="css/news.css" rel="stylesheet" type="text/css">
|
43
|
+
</head>
|
44
|
+
|
45
|
+
<body onload="MM_preloadImages('images/index/over_03.gif','images/index/over_04.gif','images/index/over_05.gif','images/index/over_06.gif','images/index/over_07.gif','images/index/over_08.gif')">
|
46
|
+
<table width="996" border="0" align="center" cellpadding="0" cellspacing="0">
|
47
|
+
<tr>
|
48
|
+
<td align="left" valign="top"><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="996" height="324">
|
49
|
+
<param name="movie" value="swf/01.swf">
|
50
|
+
<param name="quality" value="high">
|
51
|
+
<param name="wmode" value="opaque">
|
52
|
+
<param name="swfversion" value="8.0.35.0">
|
53
|
+
<!-- 此 param 標籤會提示使用 Flash Player 6.0 r65 和更新版本的使用者下載最新版本的 Flash Player。如果您不想讓使用者看到這項提示,請將其刪除。 -->
|
54
|
+
<param name="expressinstall" value="Scripts/expressInstall.swf">
|
55
|
+
<!-- 下一個物件標籤僅供非 IE 瀏覽器使用。因此,請使用 IECC 將其自 IE 隱藏。 -->
|
56
|
+
<!--[if !IE]>-->
|
57
|
+
<object type="application/x-shockwave-flash" data="swf/01.swf" width="996" height="324">
|
58
|
+
<!--<![endif]-->
|
59
|
+
<param name="quality" value="high">
|
60
|
+
<param name="wmode" value="opaque">
|
61
|
+
<param name="swfversion" value="8.0.35.0">
|
62
|
+
<param name="expressinstall" value="Scripts/expressInstall.swf">
|
63
|
+
<!-- 瀏覽器會為使用 Flash Player 6.0 和更早版本的使用者顯示下列替代內容。 -->
|
64
|
+
<div>
|
65
|
+
<h4>這個頁面上的內容需要較新版本的 Adobe Flash Player。</h4>
|
66
|
+
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="取得 Adobe Flash Player" width="112" height="33"></a></p>
|
67
|
+
</div>
|
68
|
+
<!--[if !IE]>-->
|
69
|
+
</object>
|
70
|
+
<!--<![endif]-->
|
71
|
+
</object></td>
|
72
|
+
</tr>
|
73
|
+
<tr>
|
74
|
+
<td align="left" valign="top"><table width="996" border="0" cellspacing="0" cellpadding="0">
|
75
|
+
<tr>
|
76
|
+
<td width="86" align="left" valign="top"><img src="images/index/index_02.gif" width="86" height="55"></td>
|
77
|
+
<td width="156" align="left" valign="top"><a href="big5/about.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images/index/over_03.gif',1)"><img src="images/index/index_03.gif" alt="關於竹客" name="Image3" width="156" height="55" border="0" id="Image3"></a></td>
|
78
|
+
<td width="126" align="left" valign="top"><a href="big5/information.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/index/over_04.gif',1)"><img src="images/index/index_04.gif" alt="乘車資訊" name="Image4" width="126" height="55" border="0" id="Image4"></a></td>
|
79
|
+
<td width="127" align="left" valign="top"><a href="big5/service.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/index/over_05.gif',1)"><img src="images/index/index_05.gif" alt="服務據點" name="Image5" width="127" height="55" border="0" id="Image5"></a></td>
|
80
|
+
<td width="125" align="left" valign="top"><a href="big5/hire.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','images/index/over_06.gif',1)"><img src="images/index/index_06.gif" alt="招租訊息" name="Image6" width="125" height="55" border="0" id="Image6"></a></td>
|
81
|
+
<td width="126" align="left" valign="top"><a href="big5/job.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','images/index/over_07.gif',1)"><img src="images/index/index_07.gif" alt="人才招募" name="Image7" width="126" height="55" border="0" id="Image7"></a></td>
|
82
|
+
<td width="76" align="left" valign="top"><a href="big5/contact.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','images/index/over_08.gif',1)"><img src="images/index/index_08.gif" alt="與我聯絡" name="Image8" width="181" height="55" border="0" id="Image8"></a></td>
|
83
|
+
<td width="174" align="left" valign="top"><img src="images/index/index_09.gif" width="69" height="55"></td>
|
84
|
+
</tr>
|
85
|
+
</table></td>
|
86
|
+
</tr>
|
87
|
+
<tr>
|
88
|
+
<td align="left" valign="top"><img src="images/index/index_10.gif" width="996" height="27"></td>
|
89
|
+
</tr>
|
90
|
+
<tr>
|
91
|
+
<td align="left" valign="top" bgcolor="#FFFFFF"><table width="996" border="0" cellspacing="0" cellpadding="0">
|
92
|
+
<tr>
|
93
|
+
<td width="87" align="left" valign="top"><img src="images/index/index_11.gif" alt="" width="87" height="179"></td>
|
94
|
+
<td width="154" align="left" valign="top"><table width="154" border="0" cellspacing="0" cellpadding="0">
|
95
|
+
<tr>
|
96
|
+
<td align="left" valign="top"><a href="big5/ic.asp"><img src="images/index/index_12.gif" alt="IC票證服務" width="154" height="43" border="0"></a></td>
|
97
|
+
</tr>
|
98
|
+
<tr>
|
99
|
+
<td height="9" align="left" valign="top"></td>
|
100
|
+
</tr>
|
101
|
+
<tr>
|
102
|
+
<td align="left" valign="top"><a href="big5/Business.asp"><img src="images/index/index_24.gif" alt="大客車租賃業務" width="154" height="43" border="0"></a></td>
|
103
|
+
</tr>
|
104
|
+
<tr>
|
105
|
+
<td height="9" align="left" valign="top"></td>
|
106
|
+
</tr>
|
107
|
+
<tr>
|
108
|
+
<td align="left" valign="top"><a href="big5/check.asp"><img src="images/index/index_28.gif" alt="對外大小車輛維修檢驗服務" width="154" height="43" border="0"></a></td>
|
109
|
+
</tr>
|
110
|
+
<tr>
|
111
|
+
<td height="9" align="left" valign="top"></td>
|
112
|
+
</tr>
|
113
|
+
<tr>
|
114
|
+
<td align="left" valign="top"><a href="big5/activite.asp"><img src="images/index/index_35.gif" alt="活動專區" width="154" height="43" border="0"></a></td>
|
115
|
+
</tr>
|
116
|
+
|
117
|
+
<tr>
|
118
|
+
<td height="9" align="left" valign="top"></td>
|
119
|
+
</tr>
|
120
|
+
<tr>
|
121
|
+
<td align="left" valign="top">
|
122
|
+
<a href="http://www.hcbus.com.tw/inquery/" target="_blank">
|
123
|
+
<img src="upload/LeftCom/5.gif" alt="" width="154" border="0">
|
124
|
+
</a>
|
125
|
+
</td>
|
126
|
+
</tr>
|
127
|
+
|
128
|
+
<tr>
|
129
|
+
<td height="9" align="left" valign="top"></td>
|
130
|
+
</tr>
|
131
|
+
<tr>
|
132
|
+
<td align="left" valign="top">
|
133
|
+
<a href="http://www.hcbus.com.tw/big5/information-4.asp" target="_blank">
|
134
|
+
<img src="upload/LeftCom/3.gif" alt="" width="154" border="0">
|
135
|
+
</a>
|
136
|
+
</td>
|
137
|
+
</tr>
|
138
|
+
|
139
|
+
<tr>
|
140
|
+
<td height="9" align="left" valign="top"></td>
|
141
|
+
</tr>
|
142
|
+
<tr>
|
143
|
+
<td align="left" valign="top">
|
144
|
+
<a href="http://blog.xuite.net/an135843/twblog" target="_blank">
|
145
|
+
<img src="upload/LeftCom/4.jpg" alt="" width="154" border="0">
|
146
|
+
</a>
|
147
|
+
</td>
|
148
|
+
</tr>
|
149
|
+
|
150
|
+
</table></td>
|
151
|
+
<td width="59" align="left" valign="top"> </td>
|
152
|
+
<td width="466" align="left" valign="top"><table width="466" border="0" cellspacing="0" cellpadding="0">
|
153
|
+
<tr>
|
154
|
+
<td align="left" valign="top"><img src="images/index/index_14.gif" alt="最新消息" width="466" height="40" border="0" usemap="#Map"></td>
|
155
|
+
</tr>
|
156
|
+
<tr>
|
157
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
158
|
+
|
159
|
+
<tr>
|
160
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
161
|
+
<tr>
|
162
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
163
|
+
<tr>
|
164
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
165
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/10/8</td>
|
166
|
+
<td width="60%" align="left" valign="top"><a href="big5/news_in.asp?id=125&page=">(中壢永樂路改道)配合「臺灣桃園機場...</a></td>
|
167
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
168
|
+
</tr>
|
169
|
+
</table></td>
|
170
|
+
</tr>
|
171
|
+
<tr>
|
172
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
173
|
+
</tr>
|
174
|
+
</table></td>
|
175
|
+
</tr>
|
176
|
+
|
177
|
+
<tr>
|
178
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
179
|
+
<tr>
|
180
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
181
|
+
<tr>
|
182
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
183
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/30</td>
|
184
|
+
<td width="60%" align="left" valign="top"><a href="big5/news_in.asp?id=121&page=">自103年10月1日起快捷5號公車繞...</a></td>
|
185
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
186
|
+
</tr>
|
187
|
+
</table></td>
|
188
|
+
</tr>
|
189
|
+
<tr>
|
190
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
191
|
+
</tr>
|
192
|
+
</table></td>
|
193
|
+
</tr>
|
194
|
+
|
195
|
+
<tr>
|
196
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
197
|
+
<tr>
|
198
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
199
|
+
<tr>
|
200
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
201
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/27</td>
|
202
|
+
<td width="60%" align="left" valign="top"><a href="big5/news_in.asp?id=120&page=">103年10月1日起辦理55、55區...</a></td>
|
203
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
204
|
+
</tr>
|
205
|
+
</table></td>
|
206
|
+
</tr>
|
207
|
+
<tr>
|
208
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
209
|
+
</tr>
|
210
|
+
</table></td>
|
211
|
+
</tr>
|
212
|
+
|
213
|
+
<tr>
|
214
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
215
|
+
<tr>
|
216
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
217
|
+
<tr>
|
218
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
219
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/25</td>
|
220
|
+
<td width="60%" align="left" valign="top"><a href="big5/news_in.asp?id=122&page=">自103.10.1起新竹縣快捷5號公...</a></td>
|
221
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
222
|
+
</tr>
|
223
|
+
</table></td>
|
224
|
+
</tr>
|
225
|
+
<tr>
|
226
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
227
|
+
</tr>
|
228
|
+
</table></td>
|
229
|
+
</tr>
|
230
|
+
|
231
|
+
<tr>
|
232
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
233
|
+
<tr>
|
234
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
235
|
+
<tr>
|
236
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
237
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/12</td>
|
238
|
+
<td width="60%" align="left" valign="top"><a href="big5/news_in.asp?id=117&page=">103.9.14起【9010 新竹-...</a></td>
|
239
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
240
|
+
</tr>
|
241
|
+
</table></td>
|
242
|
+
</tr>
|
243
|
+
<tr>
|
244
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
245
|
+
</tr>
|
246
|
+
</table></td>
|
247
|
+
</tr>
|
248
|
+
|
249
|
+
<tr>
|
250
|
+
<td align="left" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
251
|
+
<tr>
|
252
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
253
|
+
<tr>
|
254
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
255
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/12</td>
|
256
|
+
<td width="60%" align="left" valign="top"><a href="big5/news_in.asp?id=116&page=">103.9.15起新竹市免費公車-7...</a></td>
|
257
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
258
|
+
</tr>
|
259
|
+
</table></td>
|
260
|
+
</tr>
|
261
|
+
<tr>
|
262
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
263
|
+
</tr>
|
264
|
+
</table></td>
|
265
|
+
</tr>
|
266
|
+
|
267
|
+
</table></td>
|
268
|
+
</tr>
|
269
|
+
<tr>
|
270
|
+
<td align="left" valign="top"><img src="images/index/index_34.gif" alt="失物招領" width="466" height="49" border="0" usemap="#Map2"></td>
|
271
|
+
</tr>
|
272
|
+
<tr>
|
273
|
+
<td align="center" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
|
274
|
+
|
275
|
+
<tr>
|
276
|
+
<td align="left" valign="top"><table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
|
277
|
+
<tr>
|
278
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
279
|
+
<tr>
|
280
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
281
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/10/12</td>
|
282
|
+
<td width="60%" align="left" valign="top"><a href="big5/lost.asp">拾擭錢包</a></td>
|
283
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
284
|
+
</tr>
|
285
|
+
</table></td>
|
286
|
+
</tr>
|
287
|
+
<tr>
|
288
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
289
|
+
</tr>
|
290
|
+
</table></td>
|
291
|
+
</tr>
|
292
|
+
|
293
|
+
<tr>
|
294
|
+
<td align="left" valign="top"><table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
|
295
|
+
<tr>
|
296
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
297
|
+
<tr>
|
298
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
299
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/29</td>
|
300
|
+
<td width="60%" align="left" valign="top"><a href="big5/lost.asp">拾擭皮夾(咖啡色)</a></td>
|
301
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
302
|
+
</tr>
|
303
|
+
</table></td>
|
304
|
+
</tr>
|
305
|
+
<tr>
|
306
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
307
|
+
</tr>
|
308
|
+
</table></td>
|
309
|
+
</tr>
|
310
|
+
|
311
|
+
<tr>
|
312
|
+
<td align="left" valign="top"><table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
|
313
|
+
<tr>
|
314
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
315
|
+
<tr>
|
316
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
317
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/26</td>
|
318
|
+
<td width="60%" align="left" valign="top"><a href="big5/lost.asp">拾擭小布包</a></td>
|
319
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
320
|
+
</tr>
|
321
|
+
</table></td>
|
322
|
+
</tr>
|
323
|
+
<tr>
|
324
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
325
|
+
</tr>
|
326
|
+
</table></td>
|
327
|
+
</tr>
|
328
|
+
|
329
|
+
<tr>
|
330
|
+
<td align="left" valign="top"><table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
|
331
|
+
<tr>
|
332
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
333
|
+
<tr>
|
334
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
335
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/24</td>
|
336
|
+
<td width="60%" align="left" valign="top"><a href="big5/lost.asp">拾擭手提包(土黃色)</a></td>
|
337
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
338
|
+
</tr>
|
339
|
+
</table></td>
|
340
|
+
</tr>
|
341
|
+
<tr>
|
342
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
343
|
+
</tr>
|
344
|
+
</table></td>
|
345
|
+
</tr>
|
346
|
+
|
347
|
+
<tr>
|
348
|
+
<td align="left" valign="top"><table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
|
349
|
+
<tr>
|
350
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
351
|
+
<tr>
|
352
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
353
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/8</td>
|
354
|
+
<td width="60%" align="left" valign="top"><a href="big5/lost.asp">拾擭錢包</a></td>
|
355
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
356
|
+
</tr>
|
357
|
+
</table></td>
|
358
|
+
</tr>
|
359
|
+
<tr>
|
360
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
361
|
+
</tr>
|
362
|
+
</table></td>
|
363
|
+
</tr>
|
364
|
+
|
365
|
+
<tr>
|
366
|
+
<td align="left" valign="top"><table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
|
367
|
+
<tr>
|
368
|
+
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
369
|
+
<tr>
|
370
|
+
<td width="5%" align="center" valign="middle"><img src="images/icon_24.gif" alt="" width="7" height="6"></td>
|
371
|
+
<td width="19%" align="left" valign="top" class="news_date">2014/9/8</td>
|
372
|
+
<td width="60%" align="left" valign="top"><a href="big5/lost.asp">拾擭NOKLA手機</a></td>
|
373
|
+
<td width="16%" align="left" valign="top"><img src="images/icon_21.gif" alt="" width="28" height="10"></td>
|
374
|
+
</tr>
|
375
|
+
</table></td>
|
376
|
+
</tr>
|
377
|
+
<tr>
|
378
|
+
<td align="left" valign="top"><img src="images/line.gif" alt="" width="418" height="13"></td>
|
379
|
+
</tr>
|
380
|
+
</table></td>
|
381
|
+
</tr>
|
382
|
+
|
383
|
+
</table></td>
|
384
|
+
</tr>
|
385
|
+
</table></td>
|
386
|
+
<td width="154" align="left" valign="top"><table width="154" border="0" cellspacing="0" cellpadding="0">
|
387
|
+
|
388
|
+
<tr>
|
389
|
+
<td align="left" valign="top">
|
390
|
+
<a href="http://www.twnsc.com.tw/" target="_blank">
|
391
|
+
<img src="upload/RightCOm/1.gif" alt="" width="154" height="47" border="0">
|
392
|
+
</a>
|
393
|
+
</td>
|
394
|
+
</tr>
|
395
|
+
<tr>
|
396
|
+
<td height="9" align="left" valign="top"></td>
|
397
|
+
</tr>
|
398
|
+
|
399
|
+
<tr>
|
400
|
+
<td align="left" valign="top">
|
401
|
+
<a href="http://www.taiwanbus.tw/Default.aspx" target="_blank">
|
402
|
+
<img src="upload/RightCOm/2.gif" alt="" width="154" height="47" border="0">
|
403
|
+
</a>
|
404
|
+
</td>
|
405
|
+
</tr>
|
406
|
+
<tr>
|
407
|
+
<td height="9" align="left" valign="top"></td>
|
408
|
+
</tr>
|
409
|
+
|
410
|
+
<tr>
|
411
|
+
<td align="left" valign="top">
|
412
|
+
<a href="http://www.fwtravel.com.tw/" target="_blank">
|
413
|
+
<img src="upload/RightCOm/3.gif" alt="" width="154" height="47" border="0">
|
414
|
+
</a>
|
415
|
+
</td>
|
416
|
+
</tr>
|
417
|
+
<tr>
|
418
|
+
<td height="9" align="left" valign="top"></td>
|
419
|
+
</tr>
|
420
|
+
|
421
|
+
<tr>
|
422
|
+
<td align="left" valign="top">
|
423
|
+
<a href="http://hcbustds.com.tw/" target="_blank">
|
424
|
+
<img src="upload/RightCOm/4.gif" alt="" width="154" height="47" border="0">
|
425
|
+
</a>
|
426
|
+
</td>
|
427
|
+
</tr>
|
428
|
+
<tr>
|
429
|
+
<td height="9" align="left" valign="top"></td>
|
430
|
+
</tr>
|
431
|
+
|
432
|
+
<tr>
|
433
|
+
<td align="left" valign="top">
|
434
|
+
<a href="http://www.hcbus.com.tw/tour.htm" target="_blank">
|
435
|
+
<img src="upload/RightCOm/10.png" alt="" width="154" height="47" border="0">
|
436
|
+
</a>
|
437
|
+
</td>
|
438
|
+
</tr>
|
439
|
+
<tr>
|
440
|
+
<td height="9" align="left" valign="top"></td>
|
441
|
+
</tr>
|
442
|
+
|
443
|
+
<tr>
|
444
|
+
<td align="left" valign="top">
|
445
|
+
<a href="http://web.hsinchu.gov.tw/tourism/" target="_blank">
|
446
|
+
<img src="upload/RightCOm/8.jpg" alt="" width="154" height="47" border="0">
|
447
|
+
</a>
|
448
|
+
</td>
|
449
|
+
</tr>
|
450
|
+
<tr>
|
451
|
+
<td height="9" align="left" valign="top"></td>
|
452
|
+
</tr>
|
453
|
+
|
454
|
+
<tr>
|
455
|
+
<td align="left" valign="top">
|
456
|
+
<a href="http://dep-tourism.hccg.gov.tw/web/Home" target="_blank">
|
457
|
+
<img src="upload/RightCOm/7.jpg" alt="" width="154" height="47" border="0">
|
458
|
+
</a>
|
459
|
+
</td>
|
460
|
+
</tr>
|
461
|
+
<tr>
|
462
|
+
<td height="9" align="left" valign="top"></td>
|
463
|
+
</tr>
|
464
|
+
|
465
|
+
<tr>
|
466
|
+
<td align="left" valign="top">
|
467
|
+
<a href="http://www.hcbus.com.tw/modify/%E6%80%A7%E9%A8%B7%E6%93%BE%E9%98%B2%E6%B2%BB%E6%8E%AA%E6%96%BD%E8%BE%A6%E6%B3%95%E5%BC%B5%E8%B2%BC%E7%B6%B2%E7%AB%99(103.9.1).doc" target="_blank">
|
468
|
+
<img src="upload/RightCOm/11.png" alt="" width="154" height="47" border="0">
|
469
|
+
</a>
|
470
|
+
</td>
|
471
|
+
</tr>
|
472
|
+
<tr>
|
473
|
+
<td height="9" align="left" valign="top"></td>
|
474
|
+
</tr>
|
475
|
+
|
476
|
+
<tr>
|
477
|
+
<td align="left" valign="top">
|
478
|
+
<a href="https://www.youtube.com/watch?v=uz9RJzl3hYs" target="_blank">
|
479
|
+
<img src="upload/RightCOm/9.gif" alt="" width="154" height="47" border="0">
|
480
|
+
</a>
|
481
|
+
</td>
|
482
|
+
</tr>
|
483
|
+
<tr>
|
484
|
+
<td height="9" align="left" valign="top"></td>
|
485
|
+
</tr>
|
486
|
+
|
487
|
+
<tr>
|
488
|
+
<td align="left" valign="top">
|
489
|
+
<a href="http://www.railway.gov.tw/tw/" target="_blank">
|
490
|
+
<img src="upload/RightCOm/5.gif" alt="" width="154" height="47" border="0">
|
491
|
+
</a>
|
492
|
+
</td>
|
493
|
+
</tr>
|
494
|
+
<tr>
|
495
|
+
<td height="9" align="left" valign="top"></td>
|
496
|
+
</tr>
|
497
|
+
|
498
|
+
<tr>
|
499
|
+
<td align="left" valign="top">
|
500
|
+
<a href="http://www.thsrc.com.tw" target="_blank">
|
501
|
+
<img src="upload/RightCOm/6.gif" alt="" width="154" height="47" border="0">
|
502
|
+
</a>
|
503
|
+
</td>
|
504
|
+
</tr>
|
505
|
+
<tr>
|
506
|
+
<td height="9" align="left" valign="top"></td>
|
507
|
+
</tr>
|
508
|
+
|
509
|
+
</table></td>
|
510
|
+
<td width="89" align="left" valign="top"><img src="images/index/index_16.gif" alt="" width="89" height="152"></td>
|
511
|
+
</tr>
|
512
|
+
</table></td>
|
513
|
+
</tr>
|
514
|
+
|
515
|
+
<tr>
|
516
|
+
<td height="65" align="center" valign="middle" bgcolor="#F3F3F3"><table width="80%" border="0">
|
517
|
+
<tr>
|
518
|
+
<td height="25" align="center" valign="middle">地址:新竹市民族路16-1號 TEL:03-5225151~8 FAX:03-5257450<br>
|
519
|
+
</td>
|
520
|
+
</tr>
|
521
|
+
<tr>
|
522
|
+
<td height="25" align="center" valign="middle">本站圖文係新竹汽車客運股份有限公司版權所有‧盜用必究 IE8.0獲得最佳瀏覽效果</td>
|
523
|
+
</tr>
|
524
|
+
</table></td>
|
525
|
+
</tr>
|
526
|
+
|
527
|
+
</table>
|
528
|
+
|
529
|
+
<map name="Map" id="Map">
|
530
|
+
<area shape="rect" coords="380,3,433,26" href="big5/news.asp">
|
531
|
+
</map>
|
532
|
+
|
533
|
+
<map name="Map2" id="Map2">
|
534
|
+
<area shape="rect" coords="382,16,426,39" href="big5/lost.asp">
|
535
|
+
</map>
|
536
|
+
<script type="text/javascript">
|
537
|
+
<!--
|
538
|
+
swfobject.registerObject("FlashID");
|
539
|
+
//-->
|
540
|
+
</script>
|
541
|
+
</body>
|
542
|
+
</html>
|
data/bin/executable.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'busgogo'
|
2
|
+
usage = []
|
3
|
+
usage << "\n Usage : executable [number] .\n"
|
4
|
+
usage << "\nNumber 1 : Hsinchu bus\' stations."
|
5
|
+
usage << "\n Number 2 : Get bus stataion names."
|
6
|
+
usage << "\n Number 3 : Get bus stataion information in detail."
|
7
|
+
usage << "\n Number 4 : Get file (bus stataion information)bus."
|
8
|
+
fail ArgumentError, usage if ARGV.count != 1
|
9
|
+
number = ARGV[0]
|
10
|
+
scmachine = WebScraper.new
|
11
|
+
structure_output = scmachine.getwebstructure('http://www.hcbus.com.tw')
|
12
|
+
bus_station = scmachine.busstation
|
13
|
+
information = scmachine.tmp_selectstation
|
14
|
+
case number
|
15
|
+
when '1'
|
16
|
+
File.write('Structure.txt', structure_output)
|
17
|
+
when '2'
|
18
|
+
bus_station.each { |value| puts value }
|
19
|
+
when '3'
|
20
|
+
puts information
|
21
|
+
when '4'
|
22
|
+
File.write('Output.txt', information)
|
23
|
+
puts 'Please check data in Output.txt file'
|
24
|
+
else
|
25
|
+
puts '(1~4) Error input : you key in No ' << number.to_s
|
26
|
+
end
|
data/busgogo.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'busgogo'
|
5
|
+
s.version = '0.2.3'
|
6
|
+
s.date = '2014-11-09'
|
7
|
+
s.add_runtime_dependency 'nokogiri', '>= 1.6.2' # v.1.6.2 has documented problem
|
8
|
+
s.add_runtime_dependency 'mechanize'
|
9
|
+
s.summary = "BusGoGo"
|
10
|
+
s.description = "We use Hsinzhu Bus Website because we often take hsinzhu bus to somewhere. Everytime we are heading for somewhere, we go to their website(http://www.hcbus.com.tw/) to get information about their service station, time, and route. Therefore, we think it will be convenience for us to use web scraper to get specific information we want."
|
11
|
+
s.authors = ["Mavis Cheng (Cheng SyunWei), Yen Wei ,Wu ChiaChun"]
|
12
|
+
s.email = 'wei.yen.0718@gmail.com'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.homepage =
|
15
|
+
'http://rubygems.org/gems/busgogo'
|
16
|
+
end
|
data/lib/busgogo.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'mechanize'
|
4
|
+
# Class that can be used to grab data from website(http://www.hcbus.com.tw/)
|
5
|
+
class WebScraper
|
6
|
+
# @data stores information
|
7
|
+
attr_accessor :data
|
8
|
+
attr_accessor :station
|
9
|
+
attr_accessor :page
|
10
|
+
attr_accessor :output
|
11
|
+
attr_accessor :url
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@data = data
|
15
|
+
@station = station
|
16
|
+
@page = page
|
17
|
+
@output = output
|
18
|
+
@url = url
|
19
|
+
end
|
20
|
+
|
21
|
+
def getwebstructure(website)
|
22
|
+
web_data = open(website)
|
23
|
+
@data = Nokogiri.HTML(web_data)
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_output
|
27
|
+
selectstation
|
28
|
+
File.write('Output.txt', @output)
|
29
|
+
puts "\n\n\nPlease check data in Output.txt file"
|
30
|
+
end
|
31
|
+
|
32
|
+
def busstation
|
33
|
+
@url = 'http://www.hcbus.com.tw/big5/service.asp'
|
34
|
+
num, @station = 1, {}
|
35
|
+
getwebstructure(url)
|
36
|
+
@data.css("select[name='jumpMenu'] option").each do |x|
|
37
|
+
@station[num] = x.text
|
38
|
+
num += 1
|
39
|
+
end
|
40
|
+
@station
|
41
|
+
end
|
42
|
+
|
43
|
+
def selectdropdown(url, num)
|
44
|
+
tmpkey = [], tmpvalue = []
|
45
|
+
agent = Mechanize.new
|
46
|
+
form = agent.get(url).forms.first
|
47
|
+
form.field_with(name: 'jumpMenu').options[num].click
|
48
|
+
@page = form.submit
|
49
|
+
content = @page.parser.xpath("//table/tr/td[@class='map-style']")
|
50
|
+
content2 = @page.parser.xpath("//table/tr/td[@class='map-style'][1]")
|
51
|
+
content2.each { |b| tmpkey << b.text.strip }
|
52
|
+
content.each { |c| tmpvalue << c.text.strip }
|
53
|
+
filehash(tmpvalue, tmpkey)
|
54
|
+
end
|
55
|
+
|
56
|
+
def filehash(value, key)
|
57
|
+
value.each do |v|
|
58
|
+
key.each do |c|
|
59
|
+
@output << '**************************************' if v == c
|
60
|
+
end
|
61
|
+
@output << v
|
62
|
+
end
|
63
|
+
@output << '**************************************'
|
64
|
+
end
|
65
|
+
|
66
|
+
def tmp_selectstation
|
67
|
+
num, @station, @output = 1, {}, []
|
68
|
+
getwebstructure(url)
|
69
|
+
@data.css("select[name='jumpMenu'] option").each do |x|
|
70
|
+
@station[num] = x.text
|
71
|
+
num += 1
|
72
|
+
end
|
73
|
+
(0...9).each do |i|
|
74
|
+
selectdropdown(@url, i)
|
75
|
+
end
|
76
|
+
@output
|
77
|
+
end
|
78
|
+
end
|
data/spec/minitest.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/rg'
|
3
|
+
require './lib/busgogo.rb'
|
4
|
+
|
5
|
+
teststation = {
|
6
|
+
'1' => '新竹地區',
|
7
|
+
'2' => '竹東地區',
|
8
|
+
'3' => '關西地區',
|
9
|
+
'4' => '桃園地區',
|
10
|
+
'5' => '苗栗地區',
|
11
|
+
'6' => '國道班車資訊',
|
12
|
+
'7' => '一般公路資訊',
|
13
|
+
'8' => '新竹市區公車',
|
14
|
+
'9' => '桃園縣市區公車資訊',
|
15
|
+
'10' => '免費公車資訊'
|
16
|
+
}
|
17
|
+
|
18
|
+
describe 'station' do
|
19
|
+
|
20
|
+
before do
|
21
|
+
mac = WebScraper.new
|
22
|
+
@found = mac.busstation
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'find 新竹地區' do
|
26
|
+
@found[8].wont_match "\d"
|
27
|
+
end
|
28
|
+
it 'find 新竹地區' do
|
29
|
+
@found[8].wont_be_empty
|
30
|
+
end
|
31
|
+
it 'find 苗栗地區' do
|
32
|
+
@found[9].wont_be_empty
|
33
|
+
end
|
34
|
+
it 'find 新竹地區' do
|
35
|
+
@found[1].must_equal teststation['1']
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'find 苗栗地區' do
|
39
|
+
@found[5].must_equal teststation['5']
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'find 桃園縣市區公車資訊' do
|
43
|
+
@found[9].must_equal teststation['9']
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,70 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: busgogo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mavis Cheng (Cheng SyunWei), Yen Wei ,Wu ChiaChun
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
|
-
- -
|
17
|
+
- - ">="
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: 1.6.2
|
19
|
-
name: nokogiri
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.6.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: mechanize
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
|
-
name: mechanize
|
34
|
-
prerelease: false
|
35
34
|
type: :runtime
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: We use Hsinzhu Bus Website because we often take hsinzhu bus to somewhere.
|
41
|
+
description: We use Hsinzhu Bus Website because we often take hsinzhu bus to somewhere.
|
42
|
+
Everytime we are heading for somewhere, we go to their website(http://www.hcbus.com.tw/)
|
43
|
+
to get information about their service station, time, and route. Therefore, we think
|
44
|
+
it will be convenience for us to use web scraper to get specific information we
|
45
|
+
want.
|
42
46
|
email: wei.yen.0718@gmail.com
|
43
47
|
executables: []
|
44
48
|
extensions: []
|
45
49
|
extra_rdoc_files: []
|
46
|
-
files:
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- ".travis.yml"
|
53
|
+
- Gemfile
|
54
|
+
- Gemfile.lock
|
55
|
+
- Output.txt
|
56
|
+
- Procfile
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- Structure.txt
|
60
|
+
- bin/executable.rb
|
61
|
+
- busgogo.gemspec
|
62
|
+
- lib/busgogo.rb
|
63
|
+
- spec/minitest.rb
|
47
64
|
homepage: http://rubygems.org/gems/busgogo
|
48
65
|
licenses: []
|
49
66
|
metadata: {}
|
50
|
-
post_install_message:
|
67
|
+
post_install_message:
|
51
68
|
rdoc_options: []
|
52
69
|
require_paths:
|
53
70
|
- lib
|
54
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
72
|
requirements:
|
56
|
-
- -
|
73
|
+
- - ">="
|
57
74
|
- !ruby/object:Gem::Version
|
58
75
|
version: '0'
|
59
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
77
|
requirements:
|
61
|
-
- -
|
78
|
+
- - ">="
|
62
79
|
- !ruby/object:Gem::Version
|
63
80
|
version: '0'
|
64
81
|
requirements: []
|
65
|
-
rubyforge_project:
|
82
|
+
rubyforge_project:
|
66
83
|
rubygems_version: 2.4.2
|
67
|
-
signing_key:
|
84
|
+
signing_key:
|
68
85
|
specification_version: 4
|
69
86
|
summary: BusGoGo
|
70
87
|
test_files: []
|