我正试图通过邮寄请求远程触发网站上的操作。
以下是点击网站上的按钮时执行的请求示例:http://pastebin.com/raw.php?i=dd3sfzpc
以下是我发送的内容:http://pastebin.com/raw.php?i=eqsBDKUp。
我使用以下代码:
import time
import requests
import json
import urllib
session = requests.session()
login_data = {
'Username': #the mail here,
'Password': #the pass here,
'submit': 'login',
}
res = session.post(#[the url where I log in], data=login_data)
rep=session.get(#[the url from which I get the session s data]).text
#below I fetch some data I need in the post request
p=rep.find('id="__EVENTVALIDATION"')
eventval=rep[rep.find('value="',p)+len('value="'):rep.find('" />',p)]
p=rep.find('id="__VIEWSTATE"')
viewstate=rep[rep.find('value="',p)+len('value="'):rep.find('" />',p)]
p=rep.find('id="__VIEWSTATEGENERATOR"')
viewstategenerator=rep[rep.find('value="',p)+len('value="'):rep.find('" />',p)]
# parameters of the action
current_trade_currency="tx"
have="Robux" if current_trade_currency=="tx" else "Tickets"
want="Tickets" if current_trade_currency=="tx" else "Robux"
fromCur=10
toCur=100
tab={}
tab["__LASTFOCUS"]=""
tab["__EVENTTARGET"]="ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$SubmitTradeButton"
tab["__EVENTARGUMENT"]=""
tab["comments"]=""
tab["__VIEWSTATE"]=viewstate
tab["__EVENTVALIDATION"]=eventval
tab["__VIEWSTATEGENERATOR"]=viewstategenerator
tab["rdoNotifications"]="on"
tab["ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$OrderType"]="LimitOrderRadioButton"
tab["ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$HaveAmountTextBoxRestyle"]=str(fromCur)
tab["ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$HaveCurrencyDropDownList"]=str(have)
tab["ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$WantAmountTextBox"]=str(toCur)
tab["ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$WantCurrencyDropDownList"]=str(want)
tab["ctl00$ctl00$cphRoblox$cphMyRobloxContent$ctl00$AllowSplitTradesCheckBox"]="on"
headers={
'Cache-Control': 'max-age=0',
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Origin' : 'http://www.roblox.com',
'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.53 Safari/537.36',
'Content-Type' : 'application/x-www-form-urlencoded',
'Referer' : 'http://www.roblox.com/My/Money.aspx',
'Accept-Encoding' : 'gzip, deflate',
'Accept-Language' : 'en-US,en;q=0.8,fr;q=0.6'
}
session.post(#[the url where I perform the post request],data=tab).text.encode("utf-8"),headers=headers)
我看不到单击按钮时发送的发布请求与我发送的发布请求之间的任何差异。但是,我的帖子请求不会触发任何内容。
这是什么原因?
编辑:以下是网站提出的请求的一些特征的屏幕截图: