簡體   English   中英

Ruby:Mechanize無法從站點中找到我要檢查的任何內容

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

我想對特定網站使用自動登錄

所以我決定使用“機械化”

例如,像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")

但是將網址設置為http://lms.kyonggi.ac.kr/

我找不到任何內容

我嘗試了幾種功能,例如

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

但我無法在此站點中捕獲任何內容

如何從網站http://lms.kyonggi.ac.kr/獲取登錄內容

該頁面有兩個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