Comments (14)
I don't think I understood your question. Can you show the code your using?
from needle.
I means when use this module to download some url with charset=utf-8
, such as www.baidu.com,
the chinese words is unreadable.
and I saw other module use iconv-lite to encode, or provide a stream method to allow user to encode buffer.
from needle.
Ok, got it. Can you show an example of how iconv-lite is used? I'd be happy to merge it into the codebase.
from needle.
https://github.com/andris9/fetch/issues/4
https://github.com/ashtuchkin/iconv-lite
from needle.
Ok, looks simple, but it seems we'd need to pass a buffer to iconv.decode() and Needle currently handles hte response as a plain string. I just pushed a commit that grabs the charset from the content type header, but if possible I'd like you to fork and make a pull request, to make sure we get it right (I can only say Ni-hao in chinese, to start). :)
from needle.
Ok, just pushed a new brach called iconv and though everything looks right, I just cant get the same output for baidu.com as returned by cURL. Any pointers?
from needle.
hi, I had check out the iconv branch and test, everything is ok now, thanks
from needle.
Are you sure? The version I get of baidu.com is slightly different from the one I get via cURL.
from needle.
env
- win7
- chinese
- cmd encoding is gbk
- node v0.8.7
target:
- www.baidu.com , (warn, it has two page)
- one is new : http://www.baidu.com/home/show/home (use
charset=utf-8
) - one is old: http://www.baidu.com/home/page/show/classic (use
charset=gb2312
)
all of them will redirect to url www.baidu.com
step1:
- use master branch code, change the test.js#simple_get to www.baidu.com
- output :
<title>�ٶ�һ�£�����֪�� </title>
step2:
- use iconv branch code, change the test.js#simple_get to www.baidu.com
- output :
<title>百度一下,你就知道 </title>
another bug
- when use icon branch, simple_get
http://www.baidu.com/home/show/home
- error:
E:\Workspace\Git\needle>node test/test.js get E:\Workspace\Git\needle\lib\needle.js:151 charset = header && header[1].replace('charset=', '').trim(); ^ TypeError: Cannot call method 'replace' of undefined at ClientRequest. (E:\Workspace\Git\needle\lib\needle.js:151:41) at ClientRequest.g (events.js:185:14) at ClientRequest.EventEmitter.emit (events.js:88:17) at HTTPParser.parserOnIncomingClient [as onIncoming](http.js:1455:7) at HTTPParser.parserOnHeadersComplete [as onHeadersComplete](http.js:111:23) at Socket.socketOnData [as ondata](http.js:1366:20) at TCP.onread (net.js:402:27)
from needle.
Fixed! Try again and see if it works. :)
from needle.
yes, works.
I hate redirect by location.href
... which can't follow by code.
E:\Workspace\Git\needle>node test\test.js get
null
Got status code 200
<script>
location.href="http://www.baidu.com/";
</script>
from needle.
when will this publish to npm?
from needle.
Soon! I'll be out of the office all day tomorrow. :(
from needle.
Have the same problem
Solved:
needle.post(URL, { 'mode': '1' }, { decode: false }, function () {})
from needle.
Related Issues (20)
- Test failures on node v14-v16 HOT 3
- Test failures on node v4-v12
- Incorrect parsing of complex JS nested objects in POST request HOT 5
- Mangled file content when multipart-POSTing a file with a "text/*" content type HOT 2
- Very infrequent TypeError: iconv.encodingExists is not a function
- Tunnelling doesn't work in v3.1.0 HOT 12
- Proposal: Supporting User-Defined "Follow If" Conditions
- Piping needle request to Express response won't set the correct headers
- Multiple Files Upload Renames Input Field
- Uncaught asynchronous error
- Remote end closed socket abruptly errors HOT 2
- a ':' in nonce breaks digest authentication HOT 1
- Digest MD5 not working with Geovision IP Camera
- Uncaught ECONNRESET exception
- needle.get cannot guaranty getting the http stream HOT 2
- FEATURE: Retry HOT 1
- follow_set_cookies -> not working!!!
- Bug in 3.3.0: accidental creation of `global.signal`, gets caught in strict UTs
- README recommends mikeal's request HOT 3
- Multipart uploads strips date values in the request body HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from needle.