简体   繁体   English

如何使用vala(gtk)从网络获取html代码?

[英]How can I get html code from the web with vala(gtk)?

How can I get a html code from some site(eg www.google.com) using vala(gtk)? 如何使用vala(gtk)从某个网站(例如www.google.com)获取html代码? I am using Val(a)IDE for programming. 我正在使用Val(a)IDE进行编程。

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;
  }
}

Forget it, someone just give me an answer on ask ubuntu site. 算了,有人在ubuntu网站上给我一个答案。

The answer is: 答案是:

Use the Vala GIO File open shown here http://live.gnome.org/Vala/GIOSamples 使用此处显示的打开的Vala GIO文件http://live.gnome.org/Vala/GIOSamples

 var web_page = File.new_for_uri ("http://live.gnome.org/Vala"); 

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

相关问题 从html页面创建Web服务:客户端,如何获取结果而不是页面的代码来源 - create a web service from a html page: client side, how can i get result and not the code souce of the page 如何从 html 代码中提取 web 应用程序内容? - How can I extract web app content from html code? 如何从Bada的网页中获取HTML? - How can I get the HTML from a web page in Bada? 如何从html代码提取图像,然后验证是否存储在我的Web服务器中 - how I can extract images from html code and then validate if are stored in my web server 如何从我当前在机器上的浏览器中打开的网页中获取文本/html? - How can I get text/html from a web page I currently have open in a browser on my machine? 如何编写 HTML 代码以强制浏览器显示来自链接网页的 PDF? - How can I code the HTML to force a browser to display a PDF from a linked web page? 如何使用python web-scraping从html代码中读取这些单元格? - How can i read these cells from an html code with python web-scraping? 如何在 PHP 中获取网页的 HTML 代码? - How do I get the HTML code of a web page in PHP? 如何使用 python 从外部 HTML(网站)获取代码片段 - How get a fragment of the code from External HTML (web site) with python 如何从代码后面获取html页面的渲染源代码,以便我可以通过邮件发送它 - How to get rendered source code of an html page from code behind so I can send it in mail
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM