-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accented characters? � � � #118
Comments
Well, what's the encoding the page uses? You can't just throw a utf8 parser at ISO-whatever. |
Btw, he cross-posted to SO: http://stackoverflow.com/questions/8332500/module-request-how-to-properly-retrieve-accented-characters |
@thejh the page encoding is iso-8859-1, I've also tried:
and I got:
But I reading this issue #27 then http://nodejs.org/docs/v0.6.0/api/http.html#request.setEncoding
It worked. |
Have a look at the iconv library. |
Okay... but do you know why binary worked? |
Because it just takes the raw buffers data. Also, the string still isn't utf8, so don't do it. |
But in this case, what is the proper value for encoding? |
No encoding. Take it as a buffer, then stuff it into iconv. |
the confusion appears to be over "binary" and Buffer, which is also binary. "binary" is, mostly, a legacy encoding from the node 0.1.x days where we encoded all binary in to strings. in node.js 0.2 we got a Buffer object, which is a raw allocation of memory outside of v8's heap. the object is not a string, and can hold raw binary data you get out of a file descriptor and send it to another file descriptor without suffering conversion to string. in request, you can pipe() a request object to any stream and all the buffers will be sent to the destination stream. if all you're doing is taking binary data from an http request and sending to a file, socket, or http response, you should just use pipe(). |
How can I use pipe with request module? |
@mikeal Awesome! I need to scrap more than one URL in the same HTTP request (it's a webapp) and then send all these data to the response. I can't send it like that:
Is there any other way to do it instead of
? |
Which stream can I use with pipe? |
you can use any Stream :) HTTP Server responses, you can use it as the body of another request object, you can open a file write stream. anything :) |
request({url: "www.example.com", encoding: "latin1"}, function (error, response, html) { |
@vickygill69 Thanks, your answer resolve my problem |
setting encoding to null and then using the response buffer with iconv worked for me. Thanks! |
Hi!
I'm trying to scrap a web page with accented characters á é ó ú ê ã etc. I tried
encoding: utf-8
, but I'm still getting this ��� characters in the result.The text was updated successfully, but these errors were encountered: