12
일반적으로 Mechanize는 URL에서 웹 페이지를 가져오고 get 메소드의 결과는 많은 유용한 메소드를 사용할 수있는 Mechanize :: Page 객체입니다 .Ruby Mechanize가 문자열에있는 페이지를 가져 오는 방법
페이지가 문자열로되어있는 경우 동일한 Mechanize :: Page 객체를 어떻게 가져 옵니까?
require 'mechanize'
html = <<END_OF_STRING
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Page Title</title>
<style type="text/css">
</style>
</head>
<body>
<h1>This is a test</h1>
</body>
</html>
END_OF_STRING
agent = Mechanize.new
# How can I get the page result from the string html?
#page = ...