منتدى استراحات زايد

منتدى استراحات زايد (http://vb.ma7room.com/index.php)
-   منتدى أخبار المواقع والمنتديات العربية والأجنبية (http://vb.ma7room.com/forumdisplay.php?f=183)
-   -   [ غير ذلك ] تجربتي في برمجة عنبكوت بحث bot (http://vb.ma7room.com/showthread.php?t=1431183)

محروم.كوم 03-28-2014 03:00 AM

[ غير ذلك ] تجربتي في برمجة عنبكوت بحث bot
 
<div>بسم الله الرحمن الرحيم

السلام عليكم ورحمة الله وبركاته

الحمد لله رب العالمين والصلاة والسلام على سيدنا محمد خاتم الانبياء والمرسلين اما بعد :

كيفكم استاذتي الكرام في ترايدنت ان شاء الله تكونوا في اتم الصحة :)

الحمد لله قمت بتجربة برمجة عنبكوت بحث لجلب عناوين والراوبط ومحتويات الموقع كجوجل ولكنه طبعا بسيط وقيد التطوير

المهم نجحت في تطبيق خوارزميات بسيطة طبعا باستعمال دوال cUrl كوسيط للاتصال بالسيرفر وجلب المعلومات

والكود حاليا تجريببي لا ااكثر وهو كما قلت سابقا قيد التطوير :)

من مميزات العنكب :

1 - سهولة الاستعمال
2 - مفتوح المصدر
3 - جلب جميع الروابط
4 - جلب Meta Name Tag والتي تستعملها اغلب العناكب
5 - جلب عنوان الموقع
6 - جلب معلومات السيرفر
7 - امكانية تسميته

من عيوب العنكب :

1 - بطيئ قليلا
2 - قيد التجربة

وهذا الكود :

رمز PHP:


spider_name = ($spider_name);

}

if (!empty(
$storage_website_folder) && isset($storage_website_folder))
{

$this->storage_website_folder = ($storage_website_folder);

if (!
file_exists($this->storage_website_folder))
{

mkdir($storage_website_folder , "0655");
}


}

if (!empty(
$storage_file) && isset($storage_file))
{

$this->storage_file = ($storage_file);


}


return (
$this->spider_name);

return (
$this->storage_website_folder);

return (
$this->storage_file);

}
# construct method close

public function connectServer ($url,$header=false)
{
if (!empty(
$url) && isset($url))
{


// intialize curl library
$init = curl_init();

if (isset(
$init))
{
$this->curl_intialize = $init;
}

if (
filter_var($url,FILTER_VALIDATE_URL))
{

// set curl option url to connect
curl_setopt($this->curl_intialize, CURLOPT_URL , $url);

// set return transfer true to return the data
curl_setopt($this->curl_intialize, CURLOPT_RETURNTRANSFER, true);

// get site header

if (is_bool($header) || is_int($header))
{
if (
$header == true)
{

curl_setopt($this->curl_intialize, CURLOPT_HEADER , true);

}
else
{

curl_setopt($this->curl_intialize, CURLOPT_HEADER , false);


}
}
else
{
die (
"Q8mb Bot:the header prameter you must be boolean or integar type");
}

// change spider name
curl_setopt($this->curl_intialize, CURLOPT_USERAGENT , $this->spider_name);

// TIME OUT CONNECTION

curl_setopt($this->curl_intialize , CURLOPT_CONNECTTIMEOUT , 0);


$output = curl_exec($this->curl_intialize);

$info = curl_getinfo($this->curl_intialize);

if (
is_array($info) && isset($info))
{


$this->site_info = $info;


}

$connectionStatus = $this->connectionStatus();

if (
$connectionStatus == true)
{

if (isset(
$output))
{
$this->site_output = $output;

$this->storageDataIntoFile($this->storage_file);
}

}

else
{

$website_dir = ($this->storage_website_folder."/".$this->storage_file);

if (
file_exists($website_dir) && isset($website_dir))
{

unlink($website_dir);

}

die (
"Q8mb Bot:connection error
Refresh

"
);

}




}
else
{
die (
"Q8mb Bot:this url not valid !!");
}
}
else
{
die or exit (
"Q8mb Bot:please insert url !!!");
}
}
# connect server method close


public function connectionStatus ()
{
$website_info = $this->getInfo();

if (
is_array($website_info) && isset($website_info))
{

$http_code = $website_info['http_code'];

if (
$http_code>=200 && $http_codestorage_website_folder);
$storage_src = str_ireplace("\/","",$this->storage_website_folder);
$storage_src = ($this->storage_website_folder."/".$file_name);

if (isset(
$storage_src) && !empty($storage_src))
{
$open_file = fopen("".$storage_src."","w");

fwrite($open_file,$this->getContent());

if (isset(
$open_file))
{

fclose($open_file);

}

}


}
else
{
die or exit (
"Q8mb Bot:please insert file name !!!");
}
}
# storage data into file method close

public function getTitle ()
{

$storage_file = ($this->storage_website_folder."/".$this->storage_file);

if (isset(
$storage_file) && file_exists($storage_file))
{

$content=file_get_contents($storage_file);

if (isset(
$content) && !empty($content))
{

$title = explode("", $content);

$title = explode("", $title[1]);

if (
is_array($title))
{

return (
$title[0]);

}
}

}

}
# get title method close


public function getUrl ($type="href")
{

$storage_file = ($this->storage_website_folder."/".$this->storage_file);

if (isset(
$storage_file) && file_exists($storage_file))
{

$content=file_get_contents($storage_file);

if (isset(
$content) && !empty($content))
{
$url_href = [];

$url_desc = [];

$url_all = [];

preg_match_all("/\storage_website_folder."/".$this->storage_file);

if (isset(
$storage_file) && file_exists($storage_file))
{

$content=file_get_contents($storage_file);

if (isset(
$content) && !empty($content))
{

if (isset(
$name) && !empty($name))
{

if (
$name==("description"))
{

preg_match_all("/\/iU"
, $content, $meta_name , PREG_SET_ORDER);

}
else if (
$name==("author"))
{

preg_match_all("/\/iU"
, $content, $meta_name , PREG_SET_ORDER);

}
else if (
$name==("generator"))
{

preg_match_all("/\/iU"
, $content, $meta_name , PREG_SET_ORDER);


}
else if (
$name==("keywords"))
{

preg_match_all("/\/iU"
, $content, $meta_name , PREG_SET_ORDER);

}
else if (
$name==("application-name"))
{

preg_match_all("/\/iU"
, $content, $meta_name , PREG_SET_ORDER);

}
else
{
die (
"Q8mb Bot:this meta name value not found in html");
}

if (
is_array($meta_name) && isset($meta_name) && !empty($meta_name) )
{

$count_meta_name = ( count($meta_name) - 1 );

for (
$i=0; $isite_output) && !empty($this->site_output))
{

return (
$this->site_output);
}
else
{

return (
"Q8mb Bot:Access Denied !!");

}
}
# get content method close

public function getInfo ()
{
if (isset(
$this->site_info) && !empty($this->site_info))
{

if (
is_array($this->site_info))
{

return (
$this->site_info);

}
}
else
{

return (
"Q8mb Bot:Access Denied !!");

}
}
# get info method close


public function extractArray ($array)
{

if (
is_array($array) && isset($array))
{

echo (
"");

print_r ($array);

echo (
"");

}
else
{
die (
"Q8mb Bot:the pramrter you must be array");
}

}
# extract array method close

public function __destruct()
{

if (isset(
$this->curl_intialize))
{

curl_close($this->curl_intialize);

}

}
# destruct method close


}



}
else
{
die (
"The class spider already exists");
}


?>


طريقة الاستعمال :

<div style="margin:20px; margin-top:5px"> رمز PHP:
<div class="alt2"> <div dir="ltr" style="text-align:left;"> <span style="color: #000000">

$spider
= new spider("-- Q8mb Bot --","store","robot.txt");
$spider->connectServer("http://localhost/mysite/",false);


// $spider->extractArray($spider->getUrl()); preview array

echo ("وصف الموقع :

"
);
$meta_name = $spider->getMetaName("description");
$meta_name_description = $meta_name["data"];
echo (
$meta_name_description."

"
);

echo (
"مالك الموقع :

"
);
$meta_name = $spider->getMetaName("author");
$meta_name_author = $meta_name["data"];
echo (
$meta_name_author."

"
);

echo (
"الكلمات المفتاحية :

"
);
$meta_name = $spider->getMetaName("keywords");
$meta_name_keywords = $meta_name["data"];
echo (
$meta_name_keywords."

"
);


$title = $spider->getTitle();


echo (
"عنوان الموقع :

"
);

if (isset(
$title))
{
echo (
$title."

"
);
}

$urls = $spider->getUrl();

echo (
" روابط الموقع الفرعية:

"
);
for (
$i=0;$igetUrl("desc");

echo (
" الكلمات الدلالية:

"
);
for (
$i=0;$i<span style="color: #007700">


الساعة الآن 04:32 AM

Powered by vBulletin® Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By Almuhajir


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 219 220 221 222 223 224 225 226 227