This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require("express"); | |
| const app = express(); | |
| const cors = require("cors"); | |
| app.use(express.json()); | |
| app.use(cors()); | |
| const axios = require("axios"); | |
| const cheerio = require("cheerio"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // accepts the URL of an instagram page | |
| const getVideo = async url => { | |
| // calls axios to go to the page and stores the result in the html variable | |
| const html = await axios.get(url); | |
| // calls cheerio to process the html received | |
| const $ = cheerio.load(html.data); | |
| // searches the html for the videoString | |
| const videoString = $("meta[property='og:video']").attr("content"); | |
| // returns the videoString | |
| return videoString; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // the callback is an async function | |
| app.post("/api/download", async (request, response) => { | |
| console.log("request coming in..."); | |
| try { | |
| // call the getVideo function, wait for videoString and store it | |
| // in the videoLink variable | |
| const videoLink = await getVideo(request.body.url); | |
| // if we get a videoLink, send the videoLink back to the user | |
| if (videoLink !== undefined) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const app = require("./scraper"); | |
| const supertest = require("supertest"); | |
| const api = supertest(app); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // groups tests. the 10,000 value increases the timeout from the default 5000ms | |
| describe("getting video urls from instagram pages", () => { | |
| // each test goes in here | |
| }, 10000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("getting video urls from instagram pages", () => { | |
| // first test | |
| test("a url with the correct link returns an mp4 video link", async () => { | |
| const pageUrl = { | |
| url: | |
| "https://www.instagram.com/p/CA5CsiZJMEJ/?utm_source=ig_web_copy_link" | |
| }; | |
| // supertest makes the requests and stores the | |
| // response in the result variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect } from "react"; | |
| import axios from "axios"; | |
| const App = () => { | |
| const [username, setUsername] = useState(""); | |
| const [password, setPassword] = useState(""); | |
| const [user, setUser] = useState(); | |
| useEffect(() => { | |
| const loggedInUser = localStorage.getItem("user"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Document</title> | |
| <link href="styles.css" rel="stylesheet" /> | |
| <link | |
| href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" | |
| rel="stylesheet" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| min-height: 100vh; | |
| background-color: wheat; | |
| font-family: "Nunito", sans-serif; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| .card { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect } from "react"; | |
| import Posts from "./Posts"; | |
| import posts from "./postsArray"; | |
| const postsPerPage = 3; | |
| let arrayForHoldingPosts = []; | |
| const App = () => { | |
| const [postsToShow, setPostsToShow] = useState([]); | |
| const [next, setNext] = useState(3); |