【问题标题】:Asynchronous requests with Mechanize使用机械化的异步请求
【发布时间】:2013-06-23 21:34:55
【问题描述】:

我正在并行解析一堆文档,我很想使用异步网络请求来完成。

我尝试将 typhoeus 与 mechanize 集成,但在从 mechanize 传递 cookie 时遇到问题。

我的步骤:

  1. 通过 mechanize 登录并获取 cookie。
  2. 将 cookie 传递给 typhoeus 并发送请求。
  3. 使用 nokogiri 解析响应。
  4. 重复 2-3 次。

我正在发送请求:

Typhoeus::Request.new("http://example.com", headers: {'Cookie' => agent.cookies})

其中agent 是一个机械化实例。

有没有办法将 Mechanize 与 Eventmachine 或 Typhoeus 集成?

【问题讨论】:

    标签: ruby mechanize eventmachine typhoeus


    【解决方案1】:

    agent.cookies 是一个数组。也许你想要:

    agent.cookies.join('; ')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 1970-01-01
      • 2019-07-21
      相关资源
      最近更新 更多