使用用户输入下载网站正文
我想使用 Shoes 来下载用户在 edit_line 中输入的网站正文。 我怎样才能做到这一点? 谁能帮助解释为什么下面的代码不起作用? 它只是弹出一个新窗口,并且不会从输入的文本下载网站......
这是迄今为止我的代码:
Shoes.app do
stack (:left => 175, :top => 200) do
para "Enter a url:"
flow do
@url = edit_line
button "OK" do
window do
stack do
title "Searching site", :size => 16
@status = para "One moment..."
# Search site for query and print body
download @url.text do |site|
@status.text = "Body: " + site.response.body.inspect
end
end
end
end
end
end
end
I want to use shoes to be able to download the body of a website that a user enters in an edit_line. How can I make this work? Can anyone help explain why the below code does not work? It just pops up a new window, and does not download the site from the text entered....
Here's my code thus far:
Shoes.app do
stack (:left => 175, :top => 200) do
para "Enter a url:"
flow do
@url = edit_line
button "OK" do
window do
stack do
title "Searching site", :size => 16
@status = para "One moment..."
# Search site for query and print body
download @url.text do |site|
@status.text = "Body: " + site.response.body.inspect
end
end
end
end
end
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系——我想通了。 我只是没有弹出一个新窗口,它可以很好地下载并打印正文。 :)
Nevermind - I figured it out. I just didn't pop to a new window and it downloads and prints the body fine. : )