简体   繁体   English

Ruby:Mechanize无法从站点中找到我要检查的任何内容

[英]Ruby : Mechanize cannot find any content from the site what i want to check

i want use auto login for specific web site 我想对特定网站使用自动登录

so i decided to use "Mechanize" 所以我决定使用“机械化”

In example, like google.com, It works! 例如,像google.com一样,它有效!

require 'rubygems'
require 'mechanize'

a = Mechanize.new { |agent|
    agent.user_agent_alias ="Windows Chrome"
}

page = a.get('http://www.google.com/')

puts page.search("div")

but when set url to http://lms.kyonggi.ac.kr/ 但是将网址设置为http://lms.kyonggi.ac.kr/

I cannot find any content 我找不到任何内容

I tried several functions like 我尝试了几种功能,例如

  • page.links
  • page.search(:id=>"wrap_login")
  • page.search(".loginfrom") .... page.search(".loginfrom") ....

But I cannot catch any content in this site 但我无法在此站点中捕获任何内容

How can I get login contents from the site http://lms.kyonggi.ac.kr/ 如何从网站http://lms.kyonggi.ac.kr/获取登录内容

That page has two iframes so you need to click the iframe first, then only you can find the elements. 该页面有两个iframes因此您需要先单击iframe,然后才可以找到元素。

require 'rubygems'
require 'mechanize'

a = Mechanize.new
page = a.get('http://lms.kyonggi.ac.kr/')
p = page.frames[1].click
puts p.search("div")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM