Что нового

Закачка файла, передача локальной ссылки в переменную

andriy111

Новичок
Сообщения
58
Репутация
0
Здравствуйте уважаемые форумчане. С праздничком Всех!
Помогите реализовать последовательность:
Надо сэмулировать нажатие кнопки Download в форме
Код:
<form method="post" action="redirect.php"><div>
      <input type="hidden" name="OriginURL" value="/shop/order.php" />
      <input type="hidden" name="OrderID" value="22792" />
      <input type="submit" name="Download" value="Download" />
</form>
После чего форма передает post запрос и начинается закачивание файла, этот файл надо принять и сохранить по адресу (например) С:\Test\, после чего надо его переименовать и передать ссылку (типа С:\Test\1.zip) в переменную.

Помогите пожалуйста!
Спасибо!
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
andriy111,
Дайте ссылку или весь код страницы.
 
Автор
A

andriy111

Новичок
Сообщения
58
Репутация
0
Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>RINEX Shop - Order View</title>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
  <link href="general.css" rel="stylesheet" type="text/css" />
</head>

<body>

<h1>RINEX Shop &ndash; Order #85</h1>




<p>The following RINEX data files have been generated. You may view the details of each data file, remove single files from the order or finally submit the order and download the whole package.</p>


<form action="redirect.php?OrderID=22793" method="post" id="frmAction">
<table class="default-table orders-table" width="100%">
  <tr>
	<th scope="col">
	  <input type="hidden" name="OriginURL" value="/shop/order.php" />
	  Station</th>
	<th scope="col">Start
time</th>
	<th scope="col">End
time</th>
	<th scope="col">Duration (min.)</th>
	<th scope="col">Interval (sec.)</th>
	<th scope="col">Epochs req./ available</th>

		<th scope="col">Eff. Minutes</th>
	
		<th scope="col">Price (€)</th>
	
	<th scope="col">Eph.</th>
	<th scope="col">Action</th>
  </tr>

    <tr>
	<td><span class="vrsCoord" title="Lat: 49&deg; 50' 0'' N;  Lon: 24&deg; 1' 0'' E;  Elev: 360.0 m">VRS</span></td>

	<td>04/29/13 01:00 PM		<!--  <span class="timezoneAbbr" title="</span> -->
	</td>

	<td>01:30 PM</td>

	<td>30</td>

	<td>5</td>

	<td >360 / <span class="toolTip order-missing-epochs" title="1 epochs missing">359</span></td>

		<td>30</td>
	
		<td>1.80</td>
	
	<td>yes</td>

	<td class="toolTip" style="white-space:nowrap" >
					<input type="submit" name="Details[25714]" value="Details" />
							<input type="submit" name="Delete[25714]" value="Remove file" />
					
	</td>
  </tr>
  
  <tr>
	<!-- Horizontal black double-line -->
	<td colspan="10" class="horizontal-line"> </td>
  </tr>
  <tr>
	<td colspan="3" style="padding-top:6pt; padding-bottom: 6pt;">
	  <strong>Total:</strong></td>
	<td><strong>30</strong></td>
	<td> </td>
	<td><strong>
	  360 / <span class="toolTip order-missing-epochs" title="1 epochs missing">359</span>	</strong></td>

		<td><strong>
	  30	</strong></td>
	
		  <td><strong>1.80</strong></td>
	  </tr>
</table>
</form>

<script type="text/javascript">
<!--
function checkCommand(fileID)
{
	// Check if user has explicitly chosen a command and not left the default value "Choose action..."
	with (document.forms['frmAction'].elements['Action[' + fileID + ']']) {
		if (options.selectedIndex == 0) {
			alert("Please choose the action you want to execute from the drop-down list !");
			focus();
			return false;
		}
	}
	return true;
}
//-->
</script> 

<p>
By downloading the order you will be charged the above total price.</p>

<table cellspacing="10">
  <tr>
	    <td><form method="get" action="overview.php"><div>
      <input type="submit" value="^ Back to Overview" />
    </div></form></td>

        <td><form method="post" action="redirect.php"><div>
      <input type="hidden" name="OriginURL" value="/shop/order.php" />
      <input type="hidden" name="OrderID" value="22793" />
      <input type="submit" name="DeleteOrder" value="Cancel order"
          onclick="return confirm('Are you sure you want to delete your whole order ?');" />
    </div></form></td>
    	
	    <td><form method="post" action="redirect.php"><div>
      <input type="hidden" name="OriginURL" value="/shop/order.php" />
      <input type="hidden" name="OrderID" value="22793" />
      <input type="submit" name="Download" value="Download" />
    </div></form></td>
    <td><form method="get" action="sendmail.php"><div>
      <input type="hidden" name="OriginURL" value="/shop/order.php" />
      <input type="hidden" name="OrderID" value="22793" />
      <input type="submit" value="Send by e-mail" />
    </div></form></td>
      </tr>
</table>


<p class="note">
The price calculation is based on the duration and independent of the interval. Only available epochs are considered.</p>

<p class="note">All times are in the GPS time system.</p>

</body>
</html>
Надеюсь на помощь!
спасибо!
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
andriy111,
Нажать на кнопку можно примерно так.
Код:
#include <IE.au3>

_IEErrorHandlerRegister()

$sUrl = @ScriptDir & '\htm.html';url
Do
$oIE = _IECreate($sUrl)
If @error Then ExitLoop
$oTemp = _IEFormGetCollection($oIE)
If @error Then ExitLoop
For $oTmp In $oTemp
	If $oTmp.action == 'redirect.php' Then
		$oTemp = _IEFormElementGetObjByName($oTmp, 'Download')
		If @error Then ContinueLoop
		_IEAction($oTemp, 'click')
		If @error Then ExitLoop 2
		_IELoadWait($oIE)
		ExitLoop 2
	EndIf
Next
Until 1
If @error Then Exit 13

Или так.
Код:
#include <IE.au3>

_IEErrorHandlerRegister()

$sUrl = @ScriptDir & '\htm.html';url
Do
	$oIE = _IECreate($sUrl)
	If @error Then ExitLoop
	$oTemp = _IEGetObjByName($oIE, 'Download')
	If @error Then ExitLoop
	_IEAction($oTemp, 'click')
	If @error Then ExitLoop
	_IELoadWait($oIE)
Until 1
If @error Then Exit 13
 
Автор
A

andriy111

Новичок
Сообщения
58
Репутация
0
madmasles, большое спасибо!
Но вот всплыло следуемые: Как сохранить сессию ранее созданого WinHttp (или же отправить кукки в IE) при эмуляции нажатия кнопки?
Можно передавать post запросы через функции IE.au3?
Спасибо!
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
andriy111,
Посмотрите здесь. (3.4. Метод Navigate)
Получить куки:
Код:
#include <IE.au3>

$oIE = _IECreate('http://autoit-script.ru/')
$oDoc = _IEDocGetObj($oIE)
MsgBox(64, 'cookie', $oDoc.cookie)
 
Автор
A

andriy111

Новичок
Сообщения
58
Репутация
0
madmasles
Спасибо!
PHPSESSID я принимаю средствами WinHTTP
Код:
$cookie=$oRequest.GetResponseHeader("Set-Cookie")
Global $cookie_mid=StringMid($cookie, 1, 42)
ConsoleWrite($cookie_mid)

потом PHPSESSID и прочие стандартные куки надо передать в IE при открытии страницы.
Как это можно реализовать?
IE куки типа :
Код:
CoordinateSystem=geographical; DeliveryType=download; EMailType=single; NotifyMail=0; RINEXType=1; Lang=ENG; PHPSESSID=99a3387f03aec44872e775f4efb313aa
П.С.
Большое спасибо за внимание к моей проблеме!
 
Верх