-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
167 lines (148 loc) · 4.82 KB
/
Copy pathindex.php
File metadata and controls
167 lines (148 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
// html grabber
// get the ptt content by using php
include("class/simple_html_dom.php");
$url_prefix = "http://www.ptt.cc";
$codejob_url = "http://www.ptt.cc/bbs/CodeJob/index.html";
$soho_url = "http://www.ptt.cc/bbs/soho/index.html";
$parttime_url = "http://www.ptt.cc/bbs/part-time/index.html";
$softjob_url = "http://www.ptt.cc/bbs/Soft_Job/index.html";
$hometeach_url = "http://www.ptt.cc/bbs/HomeTeach/index.html";
$teacher_url = "http://www.ptt.cc/bbs/teacher/index.html";
function get_result_array($url_prefix, $url){
$result_array = array();
$html = file_get_html($url);
// get the prev page
$get_url = "";
$prev_url = "";
foreach($html->find("div[class=btn-group btn-group-paging] a") as $element){
if(preg_match_all("/上頁/", $element->plaintext)){
$prev_url = $element->href;
}
}
$get_url = file_get_html("".$url_prefix."".$prev_url."");
// Find all links
foreach($get_url->find('div.title a') as $element){
array_push($result_array, $element);
}
// Find all links
foreach($html->find('div.title a') as $element){
array_push($result_array, $element);
}
// sort
krsort($result_array);
return $result_array;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Code Job Opportunity</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
<h1><a href="./">Code Job Opportunity</a></h1>
<h3>Get data from PTT</h3>
<div class="well">
<ul class="nav nav-tabs" id="myTab">
<li><a href="#codejob" data-toggle="tab">Code Job</a></li>
<li><a href="#soho" data-toggle="tab">Soho</a></li>
<li><a href="#parttime" data-toggle="tab">Part Time</a></li>
<li><a href="#softjob" data-toggle="tab">Soft Job</a></li>
<li><a href="#hometeach" data-toggle="tab">Home Teach</a></li>
<li><a href="#teacher" data-toggle="tab">Teacher</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="codejob">
<?php
$get_array = get_result_array($url_prefix, $codejob_url);
// arrange
foreach($get_array AS $result){
$gethref = $result->href;
echo "<p><a href=\"".$url_prefix."".$gethref."\" target=\"_blank\"> ".$result->plaintext."</a></p>";
}
?>
</div>
<div class="tab-pane" id="soho">
<?php
$get_array = get_result_array($url_prefix, $soho_url);
// arrange
foreach($get_array AS $result){
$gethref = $result->href;
echo "<p><a href=\"".$url_prefix."".$gethref."\" target=\"_blank\"> ".$result->plaintext."</a></p>";
}
?>
</div>
<div class="tab-pane" id="parttime">
<?php
$get_array = get_result_array($url_prefix, $parttime_url);
// arrange
foreach($get_array AS $result){
$gethref = $result->href;
echo "<p><a href=\"".$url_prefix."".$gethref."\" target=\"_blank\"> ".$result->plaintext."</a></p>";
}
?>
</div>
<div class="tab-pane" id="softjob">
<?php
$get_array = get_result_array($url_prefix, $softjob_url);
// arrange
foreach($get_array AS $result){
$gethref = $result->href;
echo "<p><a href=\"".$url_prefix."".$gethref."\" target=\"_blank\"> ".$result->plaintext."</a></p>";
}
?>
</div>
<div class="tab-pane" id="hometeach">
<?php
$get_array = get_result_array($url_prefix, $hometeach_url);
// arrange
foreach($get_array AS $result){
$gethref = $result->href;
echo "<p><a href=\"".$url_prefix."".$gethref."\" target=\"_blank\"> ".$result->plaintext."</a></p>";
}
?>
</div>
<div class="tab-pane" id="teacher">
<?php
$get_array = get_result_array($url_prefix, $teacher_url);
// arrange
foreach($get_array AS $result){
$gethref = $result->href;
echo "<p><a href=\"".$url_prefix."".$gethref."\" target=\"_blank\"> ".$result->plaintext."</a></p>";
}
?>
</div>
</div>
</div>
<div>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- CodeJob -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7789199985896905"
data-ad-slot="7790107950"
data-ad-format="link"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$(function () {
$('#myTab a:first').tab('show');
})
$('#myTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
})
</script>
</body>
</html>