Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as PHP by mind_user ( 16 years ago )
<?
include ('simple_html_dom.php');
function parse($id) {
$html = file_get_html('http://spb.menu.ru/places/show/place/'.$id);
$ret = $html->find('h1[id=place_title]');
foreach ($ret as $item){
$name = $item->plaintext;
}
if ($name){
$query = "INSERT INTO places_spb (name, type, cuisine, bill, metro, adress, phone, site, working_time) VALUES ('".trim($name)."'";
}
$ret = $html->find('div[class=info_rate]');
foreach ($ret as $item){
$type = $item->plaintext;
}
if ($type){
$query.= ",'".trim($type)."'";
}
$ret = $html->find('td');
for ($a=0; $a<count($ret);$a++){
if(($ret[$a]->plaintext) == 'Кухня: '){
$cuisine = ($ret[$a+1]->plaintext);
$query .= ",'".trim($cuisine)."'";
}
if(($ret[$a]->plaintext) == 'Счет: '){
$bill = ($ret[$a+1]->plaintext);
$query .= ",'".trim($bill)."'";
}
if(($ret[$a]->plaintext) == 'Метро: '){
$metro = ($ret[$a+1]->plaintext);
$query .= ",'".trim($metro)."'";
}
if(($ret[$a]->plaintext) == 'Адрес: '){
$adress = ($ret[$a+1]->plaintext);
$query .= ",'".trim($adress)."'";
}
if(($ret[$a]->plaintext) == 'Телефон: '){
$phone = ($ret[$a+1]->plaintext);
$query .= ",'".trim($phone)."'";
}
if(($ret[$a]->plaintext) == 'Сайт: '){
$site = ($ret[$a+1]->plaintext);
$query .= ",'".trim($site)."'";
}
if(($ret[$a]->plaintext) == 'Работаем: '){
$workingtime = ($ret[$a+1]->plaintext);
$query .= ",'".trim($workingtime)."'";
}
}
if ($name){
$query .= ");";
mysql_query($query);
$_SESSION[$count] ++;
print "Добавлено ".$_SESSION[$count]." заведений";
}
}
$connection = mysql_connect('localhost','root', ''); // настройки подключения к MySQL
mysql_select_db('catalog');// Выбор БД
$_SESSION[$count] = 0;
for ($i=1;$i<650000;$i++){ // диапазон значений
parse($i);
}
mysql_close($connection);
?>
Revise this Paste