node-request

Why doesn't request.on() work in Node.js

老子叫甜甜 提交于 2019-12-01 10:45:10
问题 I'm trying to get some data from a third party service using the node request module and return this data as string from a function. My perception was that request() returns a readable stream since you can do request(...).pipe(writeableStream) which - I thought - implies that I can do function getData(){ var string; request('someurl') .on('data', function(data){ string += data; }) .on('end', function(){ return string; }); } but this does not really work. I think I have some wrong perception

Scraping javascript generated content using request in Node.Js

▼魔方 西西 提交于 2019-11-29 13:15:29
I need to scrape some content from Google search results that only shows in browsers (I suspect it's when Javascript is enabled) – specifically, their Knowledge Graph "People also search for" content. I use a combination of request and cheerio to scrape and has already managed to force-load results from .com domain, however, the knowledgebase box does not show up in the body of my results, probably because it's javascript-generated content. Anybody knows if there's a setting I could add or another library I could use? Here's my code below. Thank you! var request = require('request'); var

Scraping javascript generated content using request in Node.Js

我的未来我决定 提交于 2019-11-28 06:39:33
问题 I need to scrape some content from Google search results that only shows in browsers (I suspect it's when Javascript is enabled) – specifically, their Knowledge Graph "People also search for" content. I use a combination of request and cheerio to scrape and has already managed to force-load results from .com domain, however, the knowledgebase box does not show up in the body of my results, probably because it's javascript-generated content. Anybody knows if there's a setting I could add or

Hidden threads in Javascript/Node that never execute user code: is it possible, and if so could it lead to an arcane possibility for a race condition?

℡╲_俬逩灬. 提交于 2019-11-27 09:36:35
See bottom of question for an update, based on comments/answers: This question is really about the possibility of hidden threads that do not execute callbacks. I have a question about a potential arcane scenario involving the Node Request module in which: A complete HTTP request is constructed and executed over the network (taking however many ms or even seconds) ... before a single function is executed at runtime on the local machine (typically in the nanoseconds?) - see below for details I am posting this mostly as a sanity check just to make sure I am not misunderstanding something about

Hidden threads in Javascript/Node that never execute user code: is it possible, and if so could it lead to an arcane possibility for a race condition?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 14:47:13
问题 See bottom of question for an update, based on comments/answers: This question is really about the possibility of hidden threads that do not execute callbacks. I have a question about a potential arcane scenario involving the Node Request module in which: A complete HTTP request is constructed and executed over the network (taking however many ms or even seconds) ... before a single function is executed at runtime on the local machine (typically in the nanoseconds?) - see below for details I