私は、以下のウェブサイト上のフォームのためのRubyやPythonのいずれかを介してPOSTリクエストを作成しようとしている:「データなし」 http://diamond-cut.com.au/holloway_cut_adviser.htmPOST要求「データがありません」
要求リターン私は私のリクエストヘッダから何かを省略していると思う
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)
ありがとうございます!出来た。 'page = RestClient.post(url、data = params、headers = {'Referer' => url})' Refererヘッダーが必要な理由を直感的に説明できますか?また、どのようにデバッグがこれを明らかにするでしょうか? –
@GolanTrevizeそれはサイトの所有者からの制限です。 –