How to open a webpage in D?

cym13 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 31 15:26:46 PDT 2015


On Monday, 31 August 2015 at 22:21:20 UTC, Taylor Hillegeist 
wrote:
> I thought that perhaps spawing a process would work but
>
> execute("PATH TO HTML 
> FILE",null,Config.none,size_t.max,dirName(exepath));
>
> Didn't seem to work? any ideas?

Use curl:

void main(string[] args) {
     import std.stdio, std.net.curl, std.algorithm;

     "http://rosettacode.org/wiki/Web_scraping"
          .byLine
          .each!writeln;
}

compile with   dmd -L-lcurl test.d

See http://dlang.org/phobos/std_net_curl.html


Also note that if you want to spawn a process you have to specify 
an executable, giving a HTML file as your example suggests 
wouldn't work.


More information about the Digitalmars-d-learn mailing list