我試圖通過Ruby或Python來進行POST請求下列網站的表格: http://diamond-cut.com.au/holloway_cut_adviser.htmPOST請求中的Ruby/Python中返回「無數據」
請求返回「無數據」。我想我從我的請求頭省略的東西
最少的代碼是用Ruby返回「無數據」(例如,用戶代理,接受包括這些參數沒有發生變化的結果。):
require 'restclient'
url='http://www.pricescope.com/hca.php'
params = {"depth_textbox" => '60',
"table_textbox" => '57',
"crown_listbox" => "0",
"crown_textbox" => '34',
"pavilion_listbox" => "0",
"pavilion_textbox" => '40.5',
"cutlet_textbox" => "0"}
page=RestClient.post(url,params)
在Python:
import requests
url='http://www.pricescope.com/hca.php'
params = {"depth_textbox" : '60',
"table_textbox" : '57',
"crown_listbox" : "0",
"crown_textbox" : '34',
"pavilion_listbox" : "0",
"pavilion_textbox" : '40.5',
"cutlet_textbox" : "0"}
r=requests.post(url,params)
謝謝!有效。爲了完整起見,下面是Ruby中的等效修復:'page = RestClient.post(url,data = params,headers = {'Referer'=> url})是否有直觀的解釋爲什麼需要Referer頭?另外,調試將如何揭示這一點? –
@GolanTrevize它是網站所有者的限制。 –