Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ◇C++, ◇Clojure, ◇Scala


[ edit | logout ]
[ sandbox | passwd ]

download a webpage

Download 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 error

If 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 -d:ssl switch to the compiler:

$ nim c -d:ssl main.nim

Or, create a file called config.nims with the following content:

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 config.nims file. Thus, simply compile the program like this:

$ nim c main.nim
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 April 25, 19:00