-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentmining.php
139 lines (132 loc) · 4.26 KB
/
contentmining.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
<html>
<head>
</head>
<body>
<form action="contentmining.php" method = "post">
<input type ="text" name="link"/>
<input type="submit" name="sub" value="check"/>
</form>
<?php
$sportskeywords = array("sports","cricket","football","fifa","hockey","scores","game","basketball","nba","espn","starsports","fixtures","racing","ferrari");
$codekeywords=array("code","javascript","scripting","stackoverflow","programming","php","java","c++","python","coding","function","method","msdn","Java","filereader","filewriter","string","codesport","w3schools","css","css3");
$shoppingkeywords = array("shopping","online","jabong","myntra","snapdeal","amazon","ebay","clothing","shoes","buy","sell","sale","buying","store","shop","brands","discount");
$foodkeywords = array("cookery","cook","food","recipe","cooking","dishes","delicacy","cuisine","multi-cuisine","menu","ingredients","lunch","dinner","chef");
if(isset($_POST['sub']))
{
$link = $_POST['link'];
$keywords ="";
$description = "";
$ch = curl_init(); // Initialising cURL
curl_setopt($ch, CURLOPT_URL, $link); // Setting cURL's URL option with the $url variable passed into the function
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
$data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
curl_close($ch);
echo $data;
$doc = new DOMDocument();
@$doc->loadHTML($data);
$nodes = $doc->getElementsByTagName('title');
$body = $doc->getElementsByTagName('body');
//get and display what you need:
$title = $nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
$nodeList = $doc->getElementsByTagName('script');
for ($nodeIdx = $nodeList->length; --$nodeIdx >= 0; ) {
$node = $nodeList->item($nodeIdx);
$node->parentNode->removeChild($node);
}
$data = $doc->saveHtml();
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'description')
$description = $meta->getAttribute('content');
if($meta->getAttribute('name') == 'keywords')
$keywords = $meta->getAttribute('content');
}
$keywords = strtolower($keywords);
$title = strtolower($title);
$description = strtolower($description);
$data = strtolower($data);
$sportlength = count($sportskeywords);
$i=0;
$sportscore=0;
while ($i<$sportlength)
{
$temp = substr_count($title,$sportskeywords[$i]);
$sportscore = $sportscore + $temp*8;
$temp=0;
$temp = substr_count($keywords,$sportskeywords[$i]);
$sportscore = $sportscore + $temp*4;
$temp=0;
$temp = substr_count($description,$sportskeywords[$i]);
$sportscore = $sportscore + $temp*2;
$temp=0;
$temp = substr_count($data,$sportskeywords[$i]);
$sportscore = $sportscore + $temp*1;
$i = $i + 1;
}
echo $sportscore;
$foodlength = count($foodkeywords);
$i=0;
$foodscore=0;
while ($i<$foodlength)
{
$temp = substr_count($title,$foodkeywords[$i]);
$foodscore = $foodscore + $temp*8;
$temp=0;
$temp = substr_count($keywords,$foodkeywords[$i]);
$foodscore = $foodscore + $temp*4;
$temp=0;
$temp = substr_count($description,$foodkeywords[$i]);
$foodscore = $foodscore + $temp*2;
$temp=0;
$temp = substr_count($data,$foodkeywords[$i]);
$foodscore = $foodscore + $temp*1;
$i = $i + 1;
}
echo "<br>";
echo $foodscore;
$codelength = count($codekeywords);
$i=0;
$codescore=0;
while ($i<$codelength)
{
$temp = substr_count($title,$codekeywords[$i]);
$codescore = $codescore + $temp*8;
$temp=0;
$temp = substr_count($keywords,$codekeywords[$i]);
$codescore = $codescore + $temp*4;
$temp=0;
$temp = substr_count($description,$codekeywords[$i]);
$codescore = $codescore + $temp*2;
$temp=0;
$temp = substr_count($data,$codekeywords[$i]);
$codescore = $codescore + $temp*1;
$i = $i + 1;
}
echo "<br>";
echo $codescore;
$shoppinglength = count($shoppingkeywords);
$i=0;
$shoppingscore=0;
while ($i<$shoppinglength)
{
$temp = substr_count($title,$shoppingkeywords[$i]);
$shoppingscore = $shoppingscore + $temp*8;
$temp=0;
$temp = substr_count($keywords,$shoppingkeywords[$i]);
$shoppingscore = $shoppingscore + $temp*4;
$temp=0;
$temp = substr_count($description,$shoppingkeywords[$i]);
$shoppingscore = $shoppingscore + $temp*2;
$temp=0;
$temp = substr_count($data,$shoppingkeywords[$i]);
$shoppingscore = $shoppingscore + $temp*1;
$i = $i + 1;
}
echo "<br>";
echo $shoppingscore;
}
?>
</body>
</html>