| 14.04.2008, 00:52 | sx000 | , , , , ... |
| 14.04.2008, 01:20 | Dem0kratizat0r | , ?
, . |
| 14.04.2008, 01:20 | spomoni |
------------------------
,
- .
Error_Reporting(E_ALL & ~E_NOTICE);
class textGenerator
{
/************************************************** ****************************************
URL .
( , cURL , )
************************************************** ****************************************
/
function download($urllist)
{
$mh = curl_multi_init();
foreach ($urllist as $i => $url)
{
$conn[$i]=curl_init($url);
curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);
curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);
curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);
curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($conn[$i],CURLOPT_HEADER,0);
curl_multi_add_handle ($mh,$conn[$i]);
}
do
{
$n = curl_multi_exec($mh,$active);
}
while ($active);
foreach ($urllist as $i => $url)
{
$con = curl_multi_getcontent($conn[$i]);
$res[$i]= $con;
// file_put_contents("debug/$i.html",$con);
curl_multi_remove_handle($mh,$conn[$i]);
curl_close($conn[$i]);
}
curl_multi_close($mh);
return $res;
}
/************************************************** ****************************************
URL .
download.
************************************************** ****************************************
/
function parse_texts($q)
{
$q = urlencode($q);
$q = 'http://www.google.com/search?q='.$q;
$goo = file_get_contents($q);
$regexp = '/<a href=\"?([^\s\"]+)\"? class=l>/';
preg_match_all($regexp,$goo,$res);
$urllist = array();
for ($i = 0; $i<count($res[1]); $i++)
{
$urllist[] = $res[1][$i];
}
$ar = $this->download($urllist);
// var_dump($urllist);
return $this->clear_up_texts($ar);
}
/************************************************** ****************************************
.
,
.
************************************************** ****************************************
/
function clear_up_texts($texts)
{
$tags = array('A', 'ABBR', 'ACRONYM', 'ADDRESS', 'AREA', 'B', 'BDO', 'BIG', 'BLOCKQUOTE', 'BR', 'CITE', 'CODE', 'DEL', 'DFN', 'EM', 'EMBED', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HR', 'I', 'IMG', 'INS', 'LI', 'MAP', 'MARQUEE', 'OL', 'P', 'PRE', 'Q', 'SAMP', 'SMALL', 'SPAN', 'STRONG', 'FONT', 'SUB', 'SUP', 'UL', 'VAR', 'TT');
$res = array();
foreach ($texts as $con)
{
$con = html_entity_decode($con);
foreach ($tags as $tag)
{
$regexp = "/<\/?".$tag."[^>]*>/i";
$con = preg_replace($regexp,"",$con);
}
$regexp = "/<head.+<\/head>/i";
$con = preg_replace($regexp,"",$con);
$regexp = "/<script[^<]+<\/script>/i";
$con = preg_replace($regexp,"",$con);
$regexp = "/<style[^<]+<\/style>/i";
$con = preg_replace($regexp,"",$con);
$regexp = "/\s+/";
$con = preg_replace($regexp," ",$con);
$con = strtolower($con);
$res[] = $con;
}
return $res;
}
/************************************************** ****************************************
.
************************************************** ****************************************
/
function generate($data, $words_co,$pages_co)
{
$result = array();
$content = "";
foreach ($data as $con)
{
$regexp = "/<[^>]+>/";
$res = preg_split($regexp,$con);
$m = 0;
foreach ($res as $kusok)
{
if (strlen($kusok)>$m)
{
$m = strlen($kusok);
$ms1 = $kusok;
}
}
$m = 0;
foreach ($res as $kusok)
{
if ((strlen($kusok)>$m)&&($kusok!=$ms1))
{
$m = strlen($kusok);
$ms2 = $kusok;
}
}
$itog = strtolower("$ms1 $ms2"
$content.="$itog ";
}
$regexp = "/[^a-z0-9]+/";
$content = preg_replace($regexp," ",$content);
$regexp = "/\s+/";
$temp = preg_split($regexp,$content);
$words = array();
for ($i = 0; $i<count($temp)-1; $i++)
{
if (!$words[$temp[$i]]) $words[$temp[$i]] = array();
$words[$temp[$i]][] = $temp[$i+1];
}
for ($i = 0; $i<$pages_co; $i++)
{
$r = rand(0,count($temp));
$w = $temp[$r];
$con = "";
for ($j = 0; $j<$words_co; $j++)
{
$r = rand(0,count($words[$w])-1);
$word = $words[$w][$r];
$w = $word;
$capit = false;
$r = rand(0,1000);
if (($r>100)&&($r<180)) $capit = true;
if ($capit)
{
$con.=".";
$word[0] = strtoupper($word[0]);
}
$con.=" $word";
}
$result[] = $con;
}
return $result;
}
}
?>
<?
/************************************************** ***************************************
- .
:
$gen->generate(__,___ ,__);
:
$gen->generate("windows articles",300,5);
.
, , $gen:
$gen = new textGenerator();
.. 5- 300 .
************************************************** ****************************************
/
//include('textgenerator.class.php');
$gen = new textGenerator();
$data = $gen->parse_texts("windows article"
$texts = $gen->generate($data,500,5);
foreach ($texts as $text)
{
echo $text;
echo "<br><hr><br>";
}
?>
|
| 14.04.2008, 03:18 | div72 |
- .
? |
| 14.04.2008, 03:23 | inferno[DGT] | spomoni, |
| 14.04.2008, 03:36 | miller | , , , , ...
|
| 14.04.2008, 07:42 | banzai | , , , , ...
, , .. . |
| 14.04.2008, 11:43 | pina | . ... n n .
.
1. ...
2. ...
- . :)
PS : ,
PPS : spomoni, clear_up_texts, ,
<?php
strip_tags($str);
?> |
| 14.04.2008, 13:01 | banzai | . ... n n .
! (http://www.armadaboard.com/topic13711.html) |
| 14.04.2008, 15:45 | sx000 | . , , , . . , . |
| 14.04.2008, 16:41 | inferno[DGT] | ... .... , . 20-30 ... ;) . ? , . . . |
| 14.04.2008, 19:18 | sx000 | , , , . , - , - . . . , . , . |
| 14.04.2008, 19:39 | WebNinja | . . . |
| 14.04.2008, 19:59 | sx000 | , . , . ... . |
| 14.04.2008, 20:49 | TerVer | sx000 ,
, ( , ), %), . , :)
, , , .., . |
| 14.04.2008, 20:58 | Dadee | +1 .
, . , . ... , , .
sx000 , . |
| 14.04.2008, 21:11 | inferno[DGT] | , :) ! , ! .... ? |
| 14.04.2008, 21:14 | sx000 | , :) |
| 14.04.2008, 21:16 | sandy | , .
, . |
| 14.04.2008, 21:17 | sx000 | Dadee , . . :) . . |
| 14.04.2008, 21:20 | sx000 | , .
, .
, , . . - :) . , . . |
| 14.04.2008, 21:24 | inferno[DGT] | sandy, ... , ... , . |
| 15.04.2008, 08:05 | deschain | inferno[DGT], . . , , .
, - , , , . , , , , , .
, , :) |
| 15.04.2008, 17:28 | RoMel | , , :)
+1 |
| 16.04.2008, 22:27 | sx000 | deschain, :) . : , ? ? ... . |
| 17.04.2008, 06:43 | Artisan | , , , MySQL , , PHP , . |
| 17.04.2008, 08:20 | deschain | sx000: http://www.fontanka.ru/2007/12/07/078/
- . |
| 17.04.2008, 08:40 | medar | . . |
| 17.04.2008, 08:49 | Artisan | . .
,
, ... |
| 17.04.2008, 09:09 | deschain | Artisan, , . |
| 17.04.2008, 09:52 | Artisan | Artisan, , .
,
, . |
| 17.04.2008, 10:25 | Artisan | , KJV , , , , .
Now these are the generations of Adam. In the day that the LORD God walking in the garden in the cool of the day; and Adam and his wife hid themselves from the presence of the LORD God formed every beast of the field; upon thy belly shalt thou go, and dust shalt thou return. And Adam called his wife's name Eve; because she was the mother of all living. Unto Adam also and to his offering he had not respect. And Cain was very wroth, and his countenance fell. And the LORD said in his heart, I will not again curse the ground any more for man's sake; for the imagination of man's heart is evil from his youth; neither will I again smite any more every thing living, as I have done. While the earth remaineth, seedtime and harvest, and cold and heat, and summer and winter, and day and night shall not cease.
Thus the heavens and the earth were finished, and all the cattle that was with him in the ark. And Noah builded an altar unto the LORD; and took of every clean fowl, and offered burnt offerings on the altar. And the LORD said unto Cain, Why art thou wroth? and why is thy countenance fallen? if thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door; and unto thee shall be his servant; God shall enlarge Japheth, and he shall dwell in the tents of Shem; and Canaan shall be his servant. And Noah lived after the flood three hundred and fifty days. |
| 17.04.2008, 10:34 | deschain | , "" , , ? |
| 17.04.2008, 10:41 | Artisan | , "" , , ?
. , , , , , , , , . |
| 17.04.2008, 10:53 | WebNinja | =) :peace: |
| 17.04.2008, 11:04 | Artisan | =)
:peace:
, KJV . , , .
http://www.gutenberg.org/etext/10 |
| 17.04.2008, 18:55 | div72 | copyrait.ru. . ( ) ;-) |
| 17.04.2008, 20:46 | Artisan | copyrait.ru. . ( ) ;-)
, , , , . |
| 19.04.2008, 01:41 | alexf2000 | . , , , , , , , , .
? - , . " ":
. , , , , , , - ? , ? , , , . . - . - ". . "". "". " , - , . . - . . , , +1 nikjnadezda . , , - , , . . . |
| 19.04.2008, 03:00 | alexf2000 | - , :
. , . - . , , - , . : - , , , , ? , ? . : . , , , , . , "", , . - , - . , ? - first:" . . "" , . , . , ? - , "". , . . - , - . , . - . , , , . ? |
| 19.04.2008, 05:56 | Artisan | ? - , . " ":
, , , , . , , . |
| 19.04.2008, 06:14 | Artisan | - , :
, , . , , . |
| 19.04.2008, 06:28 | alexf2000 | >
"" ? :) 2 4, |
| 19.04.2008, 09:38 | Artisan | >
"" ? :) 2 4,
,
,
.
,
,
,
.
,
,
.
,
.
1 =
,
2 =
,
, |
| 19.04.2008, 10:42 | Lovec | alexf2000,
. , , 2006.
, . , , . , DMI 22. |
| 19.04.2008, 11:03 | analgin | :)) :)) |
| 19.04.2008, 15:12 | alexf2000 | , . . |
| 19.04.2008, 20:36 | kiwi | alexf2000,
. , , 2006.
, . , , . , DMI 22.
. , . |
vBulletin® 3.8.4. Copyright ©2000-2010, Jelsoft Enterprises Ltd. : zCarot
|