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": "keep
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.
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 = "http://ol
> `||` - 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
**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 do
...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.
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 functi
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?
**OderWat** Great! Maybe **Araq** will want to include in the next build
something like that? :) Personally I would not mind.
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))
pa
**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 :)
{.experimental.}
import times
import threadpool
import future
let w = ["aa", "bb","cc"]
template parallelFor(
slice: Slice[int],
f:expr
) =
const a = slice.a
> 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, y
**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 wr
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 writeFile[T](filePath,iter:iterator()
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"): Ta
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 SetConsoleC
> 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 lan
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 documented
**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
**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", fmR
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.
**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.
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.
Strings are searched for as regular expressions - checking in text editors is
also done using regular expressions.
Can I do this code faster? On my computer for the file in the 3 million lines
it runs 14 seconds. When using memfiles - one second faster. While text editors
produce the same operation is much faster: AkelPad - 7 seconds, Notepad ++ -
2-3 seconds.
PS: Attempts to be played with a size of the bu
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 m
How in Nim it is possible to cause COM object of (Word|Excel).Application?
**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.
**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: pri
On Nim 0.14.02 at first hangs, then "out of memory" :).
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?
32 matches
Mail list logo