-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvnexpress.php
83 lines (82 loc) · 2.49 KB
/
vnexpress.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
<?php
/*
* A SIMPLE EXAMPLE OF WEB SCRAPING WITH PHP
* Use: http://simplehtmldom.sourceforge.net/
**/
include('simple_html_dom.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Leech bài viết từ VNExpress</title>
<style>
*{
margin:0;
padding:0;
}
#header{
background-color: blue;
color:white;
height:50px;
line-height:50px;
text-align:center;
}
#content{
margin: 2% 10%;
text-align:center;
}
#footer{
background-color: black;
color:white;
height:50px;
line-height:50px;
text-align:center;
}
</style>
</head>
<body>
<div id="header">
<h1>Leech VnExpress.Net</h1>
</div>
<div id="content">
<?php
if($_SERVER['REQUEST_METHOD'] != 'POST'){
?>
<form method='post'>
Link cần leech :<input type="text" name="url">
<br/><br/><input type="submit" value="Leech">
</form>
<?php
}else{
$url = $_POST['url'];
$html = file_get_html($url, false, null, 0);
$title = $html->find("h1[class='title_news_detail mb10']",0);
$content = $html->find("article[class='content_detail']", 0)->outertext;
$pattern_open_tag = "'<article (.*?)>'si";
$end_tag = '</article>';
$content = preg_replace ($pattern_open_tag,"",$content);
$content = str_replace($end_tag,"",$content);
$content = trim($content);
if($title == null || $content == null)
{
echo "Lỗi vui lòng kiểm tra lại link. Nếu link đúng k được vui lòng liên hệ admin";
}else{
?>
<span>Tiêu đề: </span><br/>
<textarea rows="5" cols="100"><?=$title->plaintext?></textarea><br/>
<span>Nội dung:</span>
<br/>
<textarea rows="23" cols="100"><?=$content?></textarea>
<?php
}
}
?>
</div>
<div id="footer">
<b>@2018 - TruongTC</b>
</div>
</body>
</html>