如何使用 vala(gtk) 从网络获取 html 代码?
如何使用 vala(gtk) 从某个网站(例如 www.google.com)获取 html 代码?我正在使用 Val(a)IDE 进行编程。
如果有人需要的话,这是我的代码:
public class Main
{
public static int main (string[] args)
{
Gtk.init (ref args);
Gtk.Window window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
window.title = "First test app";
window.set_default_size (320, 420);
window.position = Gtk.WindowPosition.CENTER;
window.destroy.connect(Gtk.main_quit);
var buttonBack = new Gtk.Button.with_label ("<");
var buttonForward = new Gtk.Button.with_label (">");
var buttonRefresh = new Gtk.Button.with_label ("Refresh");
var buttonStop = new Gtk.Button.with_label ("Stop");
buttonBack.set_size_request (20, 40);
buttonForward.set_size_request (20, 40);
buttonRefresh.set_size_request (20, 40);
buttonStop.set_size_request (20, 40);
//window.add (buttonBack);
var label1 = new Gtk.Label ("There will be something! :)");
label1.set_size_request (320,380);
//window.add (label1);
var hbox1 = new Gtk.HBox (true, 0);
var vbox1 = new Gtk.VBox (false, 0);
//var html = new Gtk.Widget();
//var empty = new Gtk.Label ("");
//empty.set_size_request(300, 10);
hbox1.add (buttonBack);
hbox1.add (buttonForward);
hbox1.add (buttonRefresh);
hbox1.add (buttonStop);
//hbox1.add (empty);
vbox1.add (hbox1);
vbox1.add (label1);
window.add (vbox1);
window.show_all ();
Gtk.main ();
return 0;
}
}
How can I get a html code from some site(e.g. www.google.com) using vala(gtk)? I am using Val(a)IDE for programming.
Here is my code if someone need it:
public class Main
{
public static int main (string[] args)
{
Gtk.init (ref args);
Gtk.Window window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
window.title = "First test app";
window.set_default_size (320, 420);
window.position = Gtk.WindowPosition.CENTER;
window.destroy.connect(Gtk.main_quit);
var buttonBack = new Gtk.Button.with_label ("<");
var buttonForward = new Gtk.Button.with_label (">");
var buttonRefresh = new Gtk.Button.with_label ("Refresh");
var buttonStop = new Gtk.Button.with_label ("Stop");
buttonBack.set_size_request (20, 40);
buttonForward.set_size_request (20, 40);
buttonRefresh.set_size_request (20, 40);
buttonStop.set_size_request (20, 40);
//window.add (buttonBack);
var label1 = new Gtk.Label ("There will be something! :)");
label1.set_size_request (320,380);
//window.add (label1);
var hbox1 = new Gtk.HBox (true, 0);
var vbox1 = new Gtk.VBox (false, 0);
//var html = new Gtk.Widget();
//var empty = new Gtk.Label ("");
//empty.set_size_request(300, 10);
hbox1.add (buttonBack);
hbox1.add (buttonForward);
hbox1.add (buttonRefresh);
hbox1.add (buttonStop);
//hbox1.add (empty);
vbox1.add (hbox1);
vbox1.add (label1);
window.add (vbox1);
window.show_all ();
Gtk.main ();
return 0;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
算了,有人在 Ask ubuntu 网站上给我答案了。
答案是:
Forget it, someone just give me an answer on ask ubuntu site.
The answer is: