forked from lnmi19611/insta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsta.js
55 lines (46 loc) · 1.81 KB
/
insta.js
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
const btn = document.getElementById('btn');
const ImgD = document.getElementById('imgC');
async function getOne() {
const name = document.querySelector("#name").value;
const base = "https://www.instagram.com/"
const url = "/?__a=1"
const fullUrl = base + name + url
fetch(fullUrl)
.then((data) => {
if (data.ok) {
return data.json()
}
throw new Error('Response not ok.');
})
.then(feed => generateHtml(feed))
.catch(error => console.error('Error:', error))
}
const generateHtml = (data) => {
// console.log(data);
data.graphql.user.edge_owner_to_timeline_media.edges.forEach(images => {
const img = document.createElement("img")
img.src = images.node.display_url;
img.style.width = "100%"
img.style.height = "100%"
ImgD.appendChild(img)
ImgD.appendChild(document.createElement("br"))
ImgD.appendChild(document.createElement("br"))
ImgD.appendChild(document.createElement("br"))
});
const html = `
<img src=${data.graphql.user.profile_pic_url}>
<div class="name">
<span> ${data.graphql.user.full_name} </span> <br/>
<span> ${data.graphql.user.biography} </span>
</div>
<div class="details">
<span>Following: ${data.graphql.user.edge_follow.count}</span>
<span>Followers: ${data.graphql.user.edge_followed_by.count}</span> <br/>
<span>Posts: ${data.graphql.user.edge_owner_to_timeline_media.count}</span>
<span>Email: ${data.graphql.user.business_email}</span>
<span>Category: ${data.graphql.user.business_category_name}</span>
</div>
`
const feedDiv = document.querySelector('.feed')
feedDiv.innerHTML = html
}