Skip to content

Commit 0806a1c

Browse files
committed
removed http but did json thing
1 parent afdb37a commit 0806a1c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const puppeteer = require('puppeteer');
2-
const http = require('http');
32

43
const connect = async (url) => {
54
const browser = await puppeteer.launch({args: ['--disabled-setuid-sandbox', '--no-sandbox']});
@@ -42,9 +41,16 @@ const connect = async (url) => {
4241
};
4342

4443
const getReviews = (url) => {
44+
let rev;
4545
connect(url).then((data) => {
46-
console.log(JSON.stringify(data));
46+
rev = data;
4747
});
48+
return JSON.stringify(rev);
4849
};
4950

50-
getReviews("https://www.google.fr/maps/place/A+tout+gamer+2.0/@48.9543665,2.8773257,17z/data=!3m1!4b1!4m5!3m4!1s0x47e8a17426f68255:0x6e147b67bf598b81!8m2!3d48.954363!4d2.8795144");
51+
const server = http.createServer( async (req, res) => {
52+
data = await getReviews('https://www.google.com/maps/place/PACA+PROPERTY/@43.3044293,5.3650846,845m/data=!3m2!1e3!4b1!4m5!3m4!1s0x12c9c1e868092f43:0x2ad1fc8819550843!8m2!3d43.3044254!4d5.3672733')
53+
res.setHeader('Content-Type', 'application/json');
54+
res.writeHead(200);
55+
res.end(data);
56+
});

0 commit comments

Comments
 (0)