Re: How to parse html wild?

2016-10-05 Thread Garry_Galler
Yes, python parser took all the links. For Nim need wrapper over lxml - is one of the best parser xml html. import requests import lxml.html main_page = "http://old.minjust.gov.ua/19612; session = requests.session() session.headers ={ "Connection":

Re: How to parse html wild?

2016-10-05 Thread Garry_Galler
It is just clear. It is unclear why parseHtml does not correct the error. I'm a bit later try to rewrite this code to python - perhaps there is a more advanced parser.

How to parse html wild?

2016-10-05 Thread Garry_Galler
I can not parse HTML wild.**findall** doesn't return all elements from the div element with the class _documents_ import httpclient import htmlparser import tables import strutils import streams import xmltree import strtabs var main_page =

Parallel loop iterator

2016-09-08 Thread Garry_Galler
> `||` - parallel loop iterator. Same as .. but the loop may run in parallel. Can anybody explain what kind of parallelism is here meant? And how is it supposed to work? In the example below, it works in series. import strutils var x=0 for i in 1||1000: inc x

Re: How to keep an authorized connection session?

2016-09-01 Thread Garry_Galler
**OderWat** > I guess that grab is recording cookies and send them back like a web browser > does it Yes, that's exactly what he does. **_tulayang**, Indeed, what we should do: take the cookies out of the Set-Cookie header, and then send them to the server in the Cookie header. My habit to

Re: How to keep an authorized connection session?

2016-09-01 Thread Garry_Galler
...OK. I think, understand what you mean.:)At http\basic authorization does not create any of this session, it directly mimics the browser itself, sending all the authentication information hidden from the user. Question by basic authorization withdrawn.

Re: How to keep an authorized connection session?

2016-09-01 Thread Garry_Galler
I'm sorry, OderWat, but I misunderstood your answer.:) I reframe the question: is there a means to support Nim http session, such as the module Grab (python), where the authorization session is maintained automatically, and the user need only once to make login to access the site? Or this

How to keep an authorized connection session?

2016-08-31 Thread Garry_Galler
My program uses httpbasic authorization and for each request pages from the same site every time they repeatedly send the same headers c pair of login: password. Is it possible to save the login session, and do not send headers "Authorization: Basic" & autentificate & "c L" over and over again?

Re: Error creating a template

2016-07-25 Thread Garry_Galler
**OderWat** Great! Maybe **Araq** will want to include in the next build something like that? :) Personally I would not mind.

Re: Error creating a template

2016-07-25 Thread Garry_Galler
Thank you very much for your help :) With the pragma {.closure.} now you can use the external variables in the template. But when you try to use my previous function (_writeFile_ from this thread [writeFile with iterator](http://forum.nim-lang.org///forum.nim-lang.org/t/2403))

Re: writeFile with iterator

2016-07-25 Thread Garry_Galler
**cblake** I did not know that --opt: size so affects the speed. Now I will take this into account. Thank you. Replacing writeLine to write really accelerated the code is almost 1.5 times. PS: Nim really fast. You just have to know how to use :)

Error creating a template

2016-07-25 Thread Garry_Galler
{.experimental.} import times import threadpool import future let w = ["aa", "bb","cc"] template parallelFor( slice: Slice[int], f:expr ) = const a = slice.a

Re: writeFile with iterator

2016-07-24 Thread Garry_Galler
> So why not using C# then? (evil smile) C # is bound to NET platform. And this is his main, but in many cases - a significant minus. Nim - self-sufficient, self-contained - and that I like. > That is 0.77 using this exact code I also compiled with the -d: release and --opt: size. Apparently,

Re: writeFile with iterator

2016-07-24 Thread Garry_Galler
**OderWat**,Thank you for editing the code :) And it should be a little slower import times import threadpool {.experimental.} var w = ["aa", "bb","cc"] var startTime = epochTime() parallel: for i,str in w: spawn

writeFile with iterator

2016-07-24 Thread Garry_Galler
How can I make this code work? proc enumerableRepeat[T](value: T, n: int = -1): iterator(): T = result = iterator(): T {.closure.} = var i = 0 while n == -1 or i < n: yield value i += 1 proc

Read the file in the proper encoding

2016-07-19 Thread Garry_Galler
Will it be possible in the future to add to the system a procedure for open\read file in the proper encoding? While I use this variant: import strutils proc readFile*(filePath:string, sourceEncoding:string, destEncoding:string = "UTF8"):

Re: ANSI vs ASCII in Windows Shells?

2016-07-19 Thread Garry_Galler
To display the console in Windows, I use import windows var str = encodings.convert(text, $GetConsoleCP(), "UTF-8") It will run on any computer with Windows, regardless of language locale. Or just turn on the console code page UTF-8: discard

Re: Nim vs Scala (not holywar). Compare functions for strings

2016-07-17 Thread Garry_Galler
> you can also put all of the helpers you coded into a package and publish it > with Nimble Some things, owing to their prevalence, in my opinion have to be part of standard library of language. For example, the string methods\functions **toCharArray**, **getBytes**, **reverse** are in many

Nim vs Scala (not holywar). Compare functions for strings

2016-07-16 Thread Garry_Galler
Partly preamble. A week ago, I began to learn **Scala** \- so how about **Nim** (and it's disappointing) read almost nothing (in my native language - especially). Written for **Nim** module nimfp, implements very similar functional paradigm that is in the **Scala** \- and this is well

Re: To optimize operation of replacement of lines in the file

2016-07-15 Thread Garry_Galler
**OderWat** Thank you, everything was actually easier than I thought. In MemFiles have stringify operator **$** for type MemSclise. What is interesting, with **lines** iterator code works somehow faster than code with iterator **memSlices**. Why? Works 4 seconds for a file in rows 3_000_000

Re: To optimize operation of replacement of lines in the file

2016-07-14 Thread Garry_Galler
**cblake**,thanks I was just trying to work with memSlices, but I got strange results. I'm at a loss. How to properly write? This test code: import memfiles import strutils import nre var count = 0 var line:string var fMem = memfiles.open("1.txt",

Re: To optimize operation of replacement of lines in the file

2016-07-14 Thread Garry_Galler
It is possible for this code to somehow use the blocks to read? Something like **fIn.readBuffer(addr buf [0], 4096)**. I tried, but did not understand how to do it correctly.

Re: To optimize operation of replacement of lines in the file

2016-07-14 Thread Garry_Galler
**Stefan_Salewski,cblake** Thank you so much! A simple thing - but tangible results. On my machine, the code worked 6 seconds at normal reading file and 4 seconds using memfiles.

Re: To optimize operation of replacement of lines in the file

2016-07-14 Thread Garry_Galler
Sorry, but I do not quite understand your point. (Example, if you please). Preliminary check **line.match(pattern.re).isSome** gives speed increase by 50-100 percent, in contrast to the embodiment, where it did not exist.

Re: To optimize operation of replacement of lines in the file

2016-07-14 Thread Garry_Galler
Strings are searched for as regular expressions - checking in text editors is also done using regular expressions.

Re: Nim and COM

2016-07-04 Thread Garry_Galler
In my script, I wrote on a powershell, is often used to work with Word documents - such as the creation of html content downloaded Word document, followed by editing its properties. I would like to re-write some scripts to Nim, but I have no idea how to call the Word.Application object and its

Nim and COM

2016-07-04 Thread Garry_Galler
How in Nim it is possible to cause COM object of (Word|Excel).Application?

Re: Split at an empty separator does not work

2016-07-02 Thread Garry_Galler
**Araq**, Ok. Then, I think you just need to bring to the behavior of some natural language for the behavior in case of empty separator. In some languages ​​it is permissible: javascript: console.log("test".split("")); [ 't', 'e', 's', 't' ] julia:

Re: Split at an empty separator does not work

2016-07-02 Thread Garry_Galler
**dom96**, I'm not against. Let there be an immediate error, it's better than an endless loop :). And it should be clearly reflected in the documentation.

Re: Split at an empty separator does not work

2016-06-30 Thread Garry_Galler
On Nim 0.14.02 at first hangs, then "out of memory" :).

Split at an empty separator does not work

2016-06-30 Thread Garry_Galler
import strutils echo split("test","") # does not work, compiler crashes import nre echo "test".split(re"") # so works This is mistake? It will be corrected in the future?