【发布时间】:2011-02-02 05:01:14
【问题描述】:
我正在用 ruby 做一个视频爬虫。在那里,我必须通过启用 cookie 和下载页面来登录页面。为此,我在 ruby 中使用 CURL 库。我可以成功登录,但我不能用 curl 下载里面的页面。我该如何解决这个问题或以其他方式下载页面?
我的代码是
curl = Curl::Easy.new(1st url)
curl.follow_location = true
curl.enable_cookies = true
curl.cookiefile = "cookie.txt"
curl.cookiejar = "cookie.txt"
curl.http_post(1st url,field)
curl.perform
curl = Curl::Easy.perform(2nd url)
curl.follow_location = true
curl.enable_cookies = true
curl.cookiefile = "cookie.txt"
curl.cookiejar = "cookie.txt"
curl.http_get
code = curl.body_str
【问题讨论】:
-
您应该始终发布您的代码。当我们可以从您所在的位置开始时,它会为您提供更轻松的帮助。