簡體   English   中英

使用Python將請求發送到網頁

[英]Sending requests to webpages using Python

我需要使用python將“ M6”值發送到此http://wap2.mobi/votes/?id=16552網頁。 我這樣做有一些問題,因為網站使用JavaScript提交了vlaue。

這是輸入的html源:

<div id="info">
<input type="text" id="company" name="com" size="20">
<input type="button" value="Send Now" onClick="getData();"></div>
<div class="clearfix"></div>
</div>

js代碼是:

    function getData()
        {
        var Send = document.getElementById("company").value;
        $.ajax({
           type: "POST",
           url: "../votes/comments.php?id=97775547",
           data: "com="+Send,

           beforeSend: function() {
               $("div#info").html("<img src='../loading.gif'>loding...");
           },
       success: function(result)
       {

           $("div#info").html(result);
    }

     });
        }

如果有人可以幫助我,請。

謝謝。

您可以使用請求模塊在python中發出此POST request

import requests

url = "http://wap2.mobi/votes/"
payload = {'id': '16552'}
r = requests.post(url, params=payload)
print "url : ", r.url
print "response status code : ", r.status_code

因此, 作為響應,我們得到狀態200。( 200表示-請求成功

url : http://wap2.mobi/votes/?id=16552
response status code : 200

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM