-
Notifications
You must be signed in to change notification settings - Fork 0
/
crawl_index.php
44 lines (44 loc) · 1.2 KB
/
crawl_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
<!DOCTYPE html>
<html>
<head>
<title>PHP Advanced Crawler</title>
</head>
<body>
<div id="content">
<center><h1>PHP Advanced Crawler</h1></center>
<form action="" method="POST">
<input name="url" style="width:300px;" placeholder="A URL please...." /><br/>
<input type="submit" name="submit" value="Crawl"/>
</form>
<?
if(isset($_POST['submit'])){
$crawlURL=$_POST['url'];
function isDomainAvailible($domain){
if(!filter_var($domain, FILTER_VALIDATE_URL)){
return false;
}
$curlInit = curl_init($domain);
curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curlInit,CURLOPT_HEADER,true);
curl_setopt($curlInit,CURLOPT_NOBODY,true);
curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($curlInit);
curl_close($curlInit);
if ($response) return true;
return false;
}
if(!isDomainAvailible($crawlURL)){
echo "<h2>A valid URL please.</h2>The URL you gave me was unable to access.";
}else{
echo "<p></p>Crawling $crawlURL</p>";
flush();
include("crawler.php");
}
}
?>
</div>
<?
/* http://subinsb.com/php-create-advanced-web-crawler */
?>
</body>
</html>