-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratchpad.js
More file actions
114 lines (102 loc) · 3.29 KB
/
scratchpad.js
File metadata and controls
114 lines (102 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// const axios = require('axios');
// const cheerio = require('cheerio');
// const Nightmare = require('nightmare')
const yelp = require('yelp-fusion');
const client = yelp.client('RFjX6wL0YbJSDHpkizRDX-M7eH4eqQH8qr1PSyugkS1y4Fxw4CqJ3SvC5PnmT6RPGCYsryQmIZmamkVUE6BTaOFq2ZK7ftc2QQLlIyaDrJYf2ybeBjtvyTvSJGx3XXYx');
export const myreviews = client.reviews('peter-luger-brooklyn-2').then(response => {
console.log(response.body)
return response.body
}).catch(e => {
console.log(e);
});
/////////********/THIS USED TO WORK FOR STATIC PAGES/**********////////////
// const url = 'https://www.yelp.com/biz/hibino-brooklyn?osq=sushi'
// async function getRawHTML () {
// try {
// let formattedData = []
// let response = await axios.get(url)
// let html = response.data;
// const $ = await cheerio.load(html)
// $('.review.review--with-sidebar').each((i, elem) => {
// formattedData.push({
// stars: $(elem).find('img.offscreen').attr('alt'),
// review: $(elem).find('.review-content p').html()
// })
// })
// return formattedData
// } catch (err) {
// console.log(err);
// }
// }
// getRawHTML().then((data) => {data.forEach(obj => {
// obj.score = 0
// })
// console.log('madeithere', data)
// })
/////////********/THIS WORKS/**********////////////
// const url = 'https://news.ycombinator.com/'
// axios.get(url)
// .then(response => {
// let html = response.data;
// console.log(getData(html));
// })
// .catch(error => {
// console.log(error);
// })
// let getData = html => {
// let formattedData = [];
// const $ = cheerio.load(html);
// $('table.itemlist tr td:nth-child(3)').each((i, elem) => {
// formattedData.push({
// title: $(elem).text(),
// link: $(elem).find('a.storylink').attr('href')
// });
// });
// return formattedData;
// }
/////////****/WORK IN PROGRESS****//////////
// const url = 'https://www.yelp.com/biz/hibino-brooklyn?osq=sushi'
// async function getRawHTML () {
// try {
// let formattedData = []
// let response = await axios.get(url)
// let html = response.data;
// const $ = await cheerio.load(html)
// $('.lemon--div__373c0__1mboc spinner-container__373c0__N6Hff border-color--default__373c0__2oFDT').each((i, elem) => {
// formattedData.push({
// review: $(elem).find('.lemon--p__373c0__3Qnnj text__373c0__2pB8f comment__373c0__3EKjH text-color--normal__373c0__K_MKN text-align--left__373c0__2pnx_').text()
// })
// })
// return formattedData
// } catch (err) {
// console.log(err);
// }
// }
// getRawHTML().then((data) => {
// console.log('madeithere', data)
// return data
// })
/////////////////////////
// const nightmare = Nightmare({ show: true })
// const url = 'https://news.ycombinator.com';
// nightmare
// .goto(url)
// .wait('body')
// .evaluate(() => document.querySelector('body').innerHTML)
// .end()
// .then(response => {
// console.log(getData(response));
// }).catch(err => {
// console.log(err);
// });
// let getData = html => {
// data = [];
// const $ = cheerio.load(html);
// $('table.itemlist tr td:nth-child(3)').each((i, elem) => {
// data.push({
// title : $(elem).text(),
// link : $(elem).find('a.storylink').attr('href')
// });
// });
// return data;
// }