2014-09-13 35 views
0

我使用python 3.3的請求模塊,並試圖發佈數據。這是我要發佈的數據。我已經解析了html中的值:請求模塊 - 試圖發佈

<form action="/checkoutnow/2" autocomplete="off" class="proceed" id="loginForm" method="post" name="login_form" novalidate="novalidate"> 
    <input id="loginForm" name="execution" type="hidden" value="e21s1"> <input name="token" type="hidden" value="EC-2MJ027776Y1687721"> <input id="incontext" name="incontext" type="hidden" value="0"> <input id="eventID" name="_eventId_submit" type="hidden"> 

    <div class="" id="loginFields"> 
    <div class="inputField emailField confidential"> 
     <label for="email">Email</label> <input autocomplete="off" data-validate-email="true" id="email" name="email" type="email" value=""> 

     <div class="tip tipHint"> 
     <div class="tipArrow tipArrowFront tipHintArrowFront"></div> 

     <div class="tipArrow tipArrowBack tipHintArrowBack"></div> 

     <ul class="tipText tipHintText"> 
      <li>Did you mean <a class="emailLink" href=""></a>? 
      </li> 
     </ul> 
     </div> 
    </div> 

    <div class="inputField passwordField confidential"> 
     <label for="password">Password</label> <input autocomplete="off" id="password" maxlength="22" name="password" type="password" value=""> 

     <div class="toolTip tip guestTooltip"> 
     <div class="tipArrow tipArrowFront tipErrorArrowFront"></div> 

     <div class="tipArrow tipArrowBack tipErrorArrowBack"></div> 

     <div class="tipText tipErrorText"> 
      Trouble logging in? You can try again, or <a class='submit' href='/checkoutnow/2?execution=e21s1&_eventId_guest' id='guestTooltipLink'>check out as a guest</a> 
     </div> 
     </div> 
    </div> 
    </div> 

    <div class="buttons varA"> 
    <input class="btn full continue" name="_eventId_submit" type="submit" value="Log in to PayPal"> 

    <div class="forgotPassword secondary" id="forgotPasswordSection"> 
     <a href='/us/merchantpaymentweb?cmd=_account-recovery&amp;from=PayPal' id='forgotPassword' target='_blank'>Forgot your password?</a> 
    </div> 
    <hr class="sep"> 
    <a class="btn btn-secondary submit" href="/checkoutnow/2?execution=e21s1&_eventId_guest&token=EC-2MJ027776Y1687721" id="checkoutAsAGuestBtn">Pay with Debit or Credit Card</a> 
    </div> 
</form> 

這裏是我的代碼來通過這個。我正在使用會話btw。

payload6 = {'loginFields': {'password': paypalpass, 'email': useremail}, 'token': token, 'execution': execution, 'incontext': incontext, '_eventId_submit': ''} 
r = session.post(urlnow, data=payload6) 

我相信我的問題是'loginFields',因爲我發佈後,值仍然是空的。

回答

0

您的POST數據不應該有任何嵌套的字典。 passwordemail應該是像tokenexecution這樣的頂級密鑰,而不是象現在一樣嵌套在loginFields之下。 (我認爲loginFields現在在你的有效載荷中,因爲那個<div id="loginFields">,但是這樣的包裝不應該對POST數據的結構有什麼影響。)

+0

啊,我試過之前,我開始使用嵌套字典的登錄字段和通行證/電子郵件沒有通過。 – 2014-09-13 19:44:15

0

事實證明,JavaScript生成更多的變量。感謝您的幫助。