Импорт ссылки из адресной строки.
Добавлено: 05 ноя 2009, 00:30
Подскажите, как в конце работы скрипта сохранить итоговую ссылку из адресной строки в txt файл?
форум программы
https://xn--80awbbeioodeq4h3a.xn--p1ai/forum/
https://xn--80awbbeioodeq4h3a.xn--p1ai/forum/viewtopic.php?f=2&t=279
Код: Выделить всё
$file='history_url.txt';
$f=fopen(dirname( __FILE__ ).'/'.$file,'a');
fputs($f,$webpage->get_location_url());
Код: Выделить всё
<?
require('../Templates/xedant_human_emulator.php');
////////////////КОНФИГУРАЦИЯ
$script='mylovescript'; //название скрипта
$dir=dirname(dirname( __FILE__ ));
////////////////ТЕЛО
$browser->navigate('http://google.ru/');
go_url('/');
loged( 'нажимает на ссылку');
$anchor->click_by_inner_text('Настройки поиска','true');
go_url('preferences?hl=en');
////////////////ФУНКЦИИ
function loged($text,$type=''){
global $webpage,$script,$dir;
$date=time();
$array_url=explode('/',$webpage->get_location_url());
$name_url=$date.'_'.$array_url[3];
$name_url=str_replace('?','_',$name_url);
$name_url=str_replace('&','_',$name_url);
$name_url=str_replace('-','_',$name_url);
$name_url=str_replace('=','_',$name_url);
$name_url=str_replace('/','_',$name_url);
$name_url=str_replace('\\','_',$name_url);
$dire=$dir.'/log/html/'.date('Y.m.d',$date);
if(!file_exists($dir.'/log'))mkdir($dir.'/log');
if(!file_exists($dir.'/log/html'))mkdir($dir.'/log/html');
if(!file_exists($dire)){$br='<br>';mkdir($dire);}
else $br='';
$out=(($type!='')?$type.' ':'').'<a href="file:///'.$dire.'/'.$name_url.'.html">'.date('d.m.Y H:i:s',$date).'</a> '.$text.'<br>';
$file1=fopen($dir.'/log/'.$script.'.html','a');
$file2=fopen($dire.'/'.$name_url.'.html','w');
fputs($file1,$br.$out);
fputs($file2,$webpage->get_source());
echo $out;
}
function go_url($text){
global $webpage,$browser;
sleep(1);
$browser->wait_for(30,1);
loged('переходим по ссылке: '.$webpage->get_location_url());
if(substr_count($webpage->get_location_url(),$text)==0)loged('эта ссылка уже не содержит *'.$text.'*','!');
}
$app->quit();
?>
код работает нормально,однакоrcc0023 писал(а):Код: Выделить всё
$file='history_url.txt'; $f=fopen(dirname( __FILE__ ).'/'.$file,'a'); fputs($f,$webpage->get_location_url().' ');