-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (22 loc) · 731 Bytes
/
Copy pathindex.js
File metadata and controls
31 lines (22 loc) · 731 Bytes
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
const axios = require('axios')
const express = require('express')
const cheerio = require('cheerio')
const app = express()
const PORT=8000
const search='c++'
const url='https://stackoverflow.com/search?q=' + search + '&s=22cf9f4c-05b1-47ff-9e69-b5349ba052d0'
axios(url)
.then(response=>{
const html=response.data
const $ = cheerio.load(html)
const articles=[]
$('.s-link',html).each(function () {
const title = $(this).text()
const url2 = $(this).attr('href')
articles.push(
title,
'https://stackoverflow.com' + url2)
})
console.log(articles[5])
})
app.listen(PORT, () => console.log(url))