开发者

Screen scraping Akamai's control panel using Mechanize for Ruby - Cookies Issue

I am attempting to s开发者_如何学Gocreen scrape some data from Akamai's control panel, but I am having trouble while logging in to the page via mechanize for Ruby.

require 'rubygems'
require 'mechanize'

agent = Mechanize.new

url = 'http://control.akamai.com'
page = agent.get( url )

puts page.content

Upon examining the page, I find displayed:

"Cookie support has been disabled in your browser. Please enable cookies before continuing."

The fact that the page thinks I have cookies disabled prevents me from logging in. Any thoughts?


You can specify other user agent:

agent.user_agent_alias = 'Mac Safari'

Or/And create a cookie manually:

cookie = Mechanize::Cookie.new(key, value)
cookie.domain = '.akamai.com'
cookie.path = '/'
agent.cookie_jar.add(cookie)

For more info about Ruby Mechanize cookies, read this pages:

http://mechanize.rubyforge.org/Mechanize/Cookie.html http://mechanize.rubyforge.org/Mechanize/CookieJar.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜