Maintaining cookies between Mechanize requests

前端 未结 2 1477
无人及你
无人及你 2020-12-14 10:18

I\'m trying to use the Ruby version of Mechanize to extract my employer\'s tickets from a ticket management system that we\'re moving away from that does not supply an API.<

2条回答
  •  攒了一身酷
    2020-12-14 10:58

    Mechanize would automatically send cookies obtained from the response in the consecutive request. You can use the same agent without re-new.

    require 'mechanize'
    
    @agent = Mechanize.new
    @agent.post(create_sessions_url, params, headers)
    @agent.get(ticket_url)
    

    Tested with mechanize 2.7.6.

提交回复
热议问题