appleLover
appleLover

Reputation: 15691

Scraping, My Query Parameters Are Wrong

I'm on a website using Ruby and Mechanize to pass a POST query to a site. The query that gets to the site, based on firebug, looks like this

param.PrdNo=-1&param.Type=Prop&param.RequestType=Normal&param.PropParams%5B0%5D.CrId=Base-MLB+Su+Washington+Na%40Atlanta+Brave

The QUERY I pass in my ruby code is this

QUERY = { "param.PrdNo" => "-1",
          "param.Type" => "Prop",
          "param.RequestType" => "Normal",
          "param.PropParams[0].CrId" => "Base-MLB+Su+Washington+Na@Atlanta+Brave"}

doc.agent.post(url, QUERY, content_type)

The logger prints out the following

D, [2014-08-10T14:46:24.844744 #15801] DEBUG -- : query: "param.PrdNo=-1&param.Type=Prop&param.RequestType=Normal&param.PropParams%5B0%5D.CrId=Base-MLB%2BSu%2BWashington%2BNa%40Atlanta%2BBrave"

How do I get my code to make a query that looks like the query from firebug?

Upvotes: 0

Views: 50

Answers (1)

pguardiario
pguardiario

Reputation: 55002

You could post the string:

vars = "param.PrdNo=-1&param.Type=Prop&param.RequestType=Normal&param.PropParams%5B0%5D.CrId=Base-MLB+Su+Washington+Na%40Atlanta+Brave"
doc.agent.post url, vars, content_type

It will get sent as the raw post body.

Upvotes: 1

Related Questions