Парсинг формы для гет/пост запроса

Discussion in 'PHP' started by rcc0023, 17 Apr 2009.

  1. rcc0023

    rcc0023 Elder - Старейшина

    Joined:
    3 Jul 2008
    Messages:
    100
    Likes Received:
    6
    Reputations:
    0
    Есть ли готовые варианты (с script изменением) для подготовки запроса? То есть есть форма:


    запрос брал так...
    PHP:
     $lbutx=rand(1,57); $lbuty=rand(1,17);  $game_login_u=rawurlencode($game_login); $game_pass_u=rawurlencode($game_pass);  $html=file_get_contents($url.'index.php');  $html=str_replace('"','',$html); $html=str_replace("'",'',$html); $html=str_replace('>',' >',$html); $html_2=str_replace(' ','',$html);  $text_01='<input';  $text_1=explode($text_01,$html); $text_2=explode('<form',$html); $text_3=explode('>',$text_2[1]); $text_12=explode('name=',$text_3[0]); $text_13=explode(' ',$text_12[1]); $text_14=explode('action=',$text_3[0]); $text_15=explode(' ',$text_14[1]);  $f_forma_name=$text_13[0]; $f_forma_action=$text_15[0];  $no_error_1=substr_count($html,$text_01);  while($no_error_1 >= $key){  $html_str2=explode('>',$text_1[$key]);  $html_str=$html_str2[0];  $text_4=explode('name=',$html_str); $text_5=explode(' ',$text_4[1]); $text_6=explode('type=',$html_str); $text_7=explode(' ',$text_6[1]); $text_8=explode('value=',$html_str); $text_9=explode(' ',$text_8[1]); $text_10=explode($f_forma_name.'.'.$text_5[0].'.value=',$html_2); $text_11=explode(';',$text_10[2]);  $f_name=$text_5[0]; $f_type=$text_7[0]; $f_value=$text_9[0]; $f_java_value=$text_11[0];  $limit_1=substr_count($html,$f_forma_name.'.'.$f_name.'.value'); $limit_2=substr_count($html_str,'Логин'); $limit_3=substr_count($html_str,'Имя персонажа');  if($data_form_auth!='' and $znak!='&'){$znak='&';};      if($f_type=='password'){$data_form_auth.=$znak.''.$f_name.'='.$game_pass_u;} elseif(($limit_2 || $limit_3 0) and $f_type=='text'){$data_form_auth.=$znak.$f_name.'='.$game_login_u;} elseif($limit_1==2){$data_form_auth.=$znak.$f_name.'='.$f_java_value;} elseif($f_type=='image' and $f_name=="lbut"){$data_form_auth.=$znak.'lbut.x='.$lbutx.'&lbut.y='.$lbuty;} elseif($f_type=='hidden'){$data_form_auth.=$znak.$f_name.'='.$f_value;};  ++$key;                           };
    в итоге получалось по типу такого: login=rcc0023&pass=hohoho&preseted=1

    Как можно сделать оптимальней?
     
    #1 rcc0023, 17 Apr 2009
    Last edited: 17 Apr 2009
  2. rcc0023

    rcc0023 Elder - Старейшина

    Joined:
    3 Jul 2008
    Messages:
    100
    Likes Received:
    6
    Reputations:
    0
    более раскрыто...
     
    #2 rcc0023, 17 Apr 2009
    Last edited: 17 Apr 2009
  3. Gifts

    Gifts Green member

    Joined:
    25 Apr 2008
    Messages:
    2,494
    Likes Received:
    807
    Reputations:
    614
    Зачем каждый раз парсить форму, особенно, когда он не меняется? Для логина на HWM надо передавать :

    PHP:
    'LOGIN_redirect=1&login='.$login.'&lreseted=1&pass='.$passw.'&preseted=1&lbut.x=61&lbut.y=13'
    Вот для записи на работу - да, надо будет парсить страницу
     
    _________________________
  4. Gar|k

    Gar|k Moderator

    Joined:
    20 Mar 2009
    Messages:
    1,166
    Likes Received:
    266
    Reputations:
    82
    rcc0023 учи регулярки... уже в 4 темах отвечал подобных
    в одной даже очень подробно описал что да как...
     
    _________________________