-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
218 lines (201 loc) · 4.53 KB
/
index.php
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>LẤY DỮ LIỆU WEBSITE TỪ URL</title>
<link rel="stylesheet" href="">
<script src="js/jquery-3.2.1.min.js"></script>
<style>
.container{
width: 1000px;
margin:0 auto;
}
table{
/*position: absolute;
right:0;
left: 0;
bottom: 0;
top:0;*/
margin:auto;
width: 50%;
}
input[type="text"]{
width: 100%;
}
textarea{
width: 100%;
}
</style>
<script>
function post_Data(){
var url = $('#url').val();
var title = $('#attTitle').val();
var date = $('#attDate').val();
var content = $('#attContent').val();
var error = {url:"Url not empty!", title:"Title not empty!", date:"Date not empty !",content:"Content not empty !"};
if(url == ''){
alert(error["url"]);
$('#url').focus();
return false;
}
if(title == ''){
alert(error["title"]);
$('#attTitle').focus();
return false;
}
if(date == ''){
alert(error["date"]);
$('#attDate').focus();
return false;
}
// if(description == ''){
// alert(error["description"]);
// $('#attDes').focus();
// return false;
// }
if(content == ''){
alert(error["content"]);
$('#attContent').focus();
return false;
}
$.ajax({
url : 'data.php',
type : 'post',
dataType : 'json',
data : {
url : url,
title : title,
date : date,
content : content
},
success : function($result){
console.log($result[1]);
var html = '';
html += '<table border="1" cellspacing="0" cellpadding="10">';
html += '<tr>';
html += '<td colspan="2" style="color:red;border:none;font-weight:bold;text-align:center">';
html += 'DATA FROM DATABASE WHEN INSERT DATA';
html += '</td>';
html += '</tr>';
html += '<tr>';
html += '<td>';
html += 'url';
html += '</td>';
html += '<td>';
html+= $result[1];
html += '</td>';
html += '</tr>';
html += '<tr>';
html += '<td>';
html += 'title';
html += '</td>';
html += '<td>';
html+= $result[2];
html += '</td>';
html += '</tr>';
html += '<tr>';
html += '<td>';
html += 'date';
html += '</td>';
html += '<td>';
html+= $result[3];
html += '</td>';
html += '</tr>';
html += '<tr>';
html += '<td>';
html += 'description';
html += '</td>';
html += '<td>';
html+= $result[4];
html += '</td>';
html += '</tr>';
html += '<tr>';
html += '<td>';
html += 'content';
html += '</td>';
html += '<td>';
html+= $result[5];
html += '</td>';
html += '</tr>';
html += '</table>';
$('#result').html(html);
}
});
}
</script>
</head>
<body>
<div class="container">
<div style="text-align: center;">
MỜI ANH TÙNG NHẬP TEST LẤY DATA TỪ 1 URL
</div>
<hr>
<p>
Mẫu URL:
<hr>
<br>
Mẫu 1 : http://vietnamnet.vn/vn/thoi-su/rut-giay-phep-cong-ty-da-cap-thien-ngoc-minh-uy-368471.html
<br>
Các thuộc tính cần nhập của mẫu 1 :
<br>
title : h1.title
<br>
date : span.ArticleDate
<br>
content : #ArticleContent
<br>
<hr>
Mẫu 2 : http://thethao.vnexpress.net/tin-tuc/bong-da-trong-nuoc/clb-han-quoc-khong-muon-xuan-truong-ve-nuoc-doi-dau-u20-argentina-3575650.html
<br>
Các thuộc tính cần nhập của mẫu 1 :
<br>
title : #box_details_news .title_news h1
<br>
date : #box_details_news .block_timer
<br>
content : #box_details_news .fck_detail
<br>
<hr>
</p>
<form action="" method="POST">
<table border='1'>
<tr>
<td colspan="2" style="text-align: center;color:red;font-weight: bold;border:none">GET DATA WEBSITE BY URL</td>
</tr>
<tr>
<td>URL :</td>
<td>
<input type="text" value="" name="url" id="url"/>
</td>
</tr>
<tr>
<td>Please enter id | class of title:</td>
<td>
<input type="text" value="" id="attTitle" name="attTitle"/>
</td>
</tr>
<tr>
<td>Please enter id | class of date:</td>
<td>
<input type="text" value="" id="attDate" name="attDate"/>
</td>
</tr>
<tr>
<td>Please enter id | class of content:</td>
<td>
<input type="text" value="" id="attContent" name="attContent"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" name="btnSubmit" value="GET DATA" id="btnSubmit" onclick="post_Data()">
</td>
</tr>
</table>
</form>
<div id="result">
</div>
</div>
</body>
</html>