Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: Не могу спарсить и спостить форму

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Без описания
Coder1994
Отправлено: 30 Июля, 2011 - 13:07:32
Post Id


Частый гость


Покинул форум
Сообщений всего: 213
Дата рег-ции: Май 2010  
Откуда: Россия, Ростов-на-Дону


Помог: 3 раз(а)




Вот что я написал:
PHP:
скопировать код в буфер обмена
  1. <?PHP
  2. function curl($url)
  3.         {
  4.  
  5.         // if($cookies)$coockes = tempnam( './tmp', 'cookie' );
  6.  
  7.         $ch = curl_init($url);
  8.         curl_setopt($ch, CURLOPT_URL, $url);
  9.         curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; MRA 5.4 (build 02652); ru) Presto/2.2.15 Version/10.00");
  10.         curl_setopt($ch, CURLOPT_REFERER, "http://sky-phoenix.ru/index.php");
  11.         curl_setopt($ch, CURLOPT_HEADER, false);
  12.  
  13.         // curl_setopt( $ch, CURLOPT_COOKIEJAR, './tmp/cookies.txt' );
  14.  
  15.         //curl_setopt($ch, CURLOPT_COOKIEFILE, H.'/tmp/cookies.txt');
  16.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  17.  
  18.         // if($cookies)curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  19.  
  20.         $html = curl_exec($ch);
  21.         if (curl_errno($ch))
  22.                 {
  23.                 echo "cURL notice: <strong>(" . curl_errno($ch) . ")</strong> " . curl_error($ch) . "....... ";
  24.                 }
  25.  
  26.         curl_close($ch);
  27.         return $html;
  28.         }
  29. if(count($_POST) < 3){
  30. $page_text = curl("http://sky-phoenix.ru/index.php");
  31. $page_text = str_replace("\n", '', $page_text);
  32. preg_match_all('/<input type = \'hidden\' name = \'xxx\' value = \'(.*)\' \/>/U', $page_text, $s);
  33. $_SESSION['var'] = $s[1][0];
  34. ?>
  35. <html>
  36. <head>
  37. <title>Страница с формой</title>
  38. </head>
  39. <body>
  40. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  41. <form action = 'form_sender.php' method = 'POST'>
  42. <input type = 'text' name = 'string' value = 'Введите текст' />
  43. <? echo "<input type = 'hidden' name = 'xxx' value = '" . $s[1][0] . "' />"; ?>
  44. <input type = 'submit' name = 'Отправить' /></form>
  45. </body>
  46. </html>
  47. <?
  48. }else{
  49. $url = "http://sky-phoenix.ru/index.php";
  50. $postdata = array (
  51.   'string' => "$_POST[string]",
  52.   'xxx' => "$_SESSION[var]",
  53.   'Отправить' => "",
  54. );
  55. $ch = curl_init($url);
  56. curl_setopt($ch, CURLOPT_URL,$url);
  57. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  58. curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; MRA 5.4 (build 02652); ru) Presto/2.2.15 Version/10.00");
  59. curl_setopt($ch, CURLOPT_REFERER, "http://sky-phoenix.ru/index.php");
  60. curl_setopt($ch, CURLOPT_POST, 1);
  61. curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  62. $result = curl_exec($ch);
  63. echo "Успешно ", $_SESSION['var'], "<br>";
  64. }
  65. ?>
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« HTTP и PHP »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB