我试图通过Ruby或Python为以下网站上的表单发出POST请求: http://diamond-cut.com.au/holloway_cut_adviser.htm
请求返回“无数据”。'我想我从我的请求标题中省略了某些内容(例如,用户代理,接受。包括这些参数并没有改变结果)
返回的最小代码'无数据'在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)
答案 0 :(得分:2)
您需要稍微使用标题:
headers = {'Referer': 'http://www.pricescope.com/hca.php'}
r = requests.post(url, data=params, headers=headers)
print r.content
答案 1 :(得分:-1)