Witam!
Mam taki oto skrypt do pobierania artów z pewnej strony:
<?php
ini_set('max_execution_time', 300000000
); //300 seconds = 5 minutes
for ($i=2000000; $i<=3000000; $i++){
$curl=curl_init("http://ezinearticles.com/?id=$i");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$wynik=curl_exec($curl);
$findme = '<meta http-equiv="refresh" content="3; url=/">';
$findme2="<h3>You are browsing EzineArticles.com faster than a normal human would.</h3>";
preg_match_all("#\<div class=\"art_title\" style=\"margin: 15px 0px 0px 0px\"\>(.*)\<\/div\>#Usi", $wynik, $tytul);
preg_match_all("#\<div id=\"body\"\>(.*)\<\/div\>#Usi", $wynik, $tresc);
if (strpos($wynik, $findme)==true) {
echo "<font color=red>Dla i=".$i." wystapil blad!</font><br/>"; }
else if (strpos($wynik, $findme2)==true) {
$ch = curl_init('http://192.168.1.1/SubmitInternetService');
curl_setopt($ch, CURLOPT_USERPWD, 'admin:admin');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'ACTION_DISCONNECT=Disconnect');
curl_exec($ch);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'ACTION_CONNECT=Connect');
curl_exec($ch);
curl_close($ch);
echo "<font color=red>Dla i=".$i." ZRESETOWANO POŁĄCZENIE! </font><br/>";
}
else {
$cat=$cat[0][1];
$cat = $tablica[0];
$zapytanie = "SELECT id FROM kategorie WHERE nazwa='$cat'";
$id=$r[0];
if (mysql_query("INSERT INTO arty (tytul, tresc, kat) VALUES ('$tytul', '$tresc', $id)")) { echo "Dla i=".$i." dodano rekord o tytule $tytul<br/>"; }
else {
echo "<font color=red>Dla i=".$i.".</font>Blad przy dodawaniu:".mysql_error(); }
}
}
?>
Skrypt działa strasznie wolno, przez 10 godzin działania pobrał zaledwie 10k rekordów, co nie jest zadowalające.
Czy da się coś z tym zrobić?