|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
download a webpageDownload a webpage and get its content as a string. import std/httpclient proc get_page(url: string): string = let client = newHttpClient() try: client.getContent(url) except HttpRequestError as e: stderr.writeLine("Error: ", e.msg) "" proc main() = let url = "https://index.hu" html = get_page(url) echo "'" & html & "'" # ########## when isMainModule: main() SSL errorIf you try to compile it, very likely you'll get an error: Error: SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable. As the message says, pass the $ nim c -d:ssl main.nim Or, create a file called
switch("define", "ssl")
Place it next to the source code: $ tree . . ├── config.nims └── main.nim Now, when you compile your program, the nim compiler will automatically read this $ nim c main.nim |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |