본문 바로가기

Example28

[Rust] Command Line Program 제작 (28일차) // Cargo.toml 과 동일한 위치의 최상단 경로에 poem.txt 생성 I'm nobody! Who are you? Are you nobody, too? Then there's a pair of us — don't tell! They'd banish us, you know. How dreary to be somebody! How public, like a frog To tell your name the livelong day To an admiring bog! // $cargo run the poem.txt 명령어를 입력하여 실행 use std::env; use std::fs::File; use std::io::prelude::*; fn main() { let args: Vec = env::arg.. 2023. 1. 10.
[OS] Deadlock 예제 코드 (with Java, C++) [Example 1 in Java] public class DeadLock { public static void main(String[] args) throws InterruptedException { Thread mainThread = Thread.currentThread(); Thread thread1 = new Thread(new Runnable() { @Override public void run() { try { mainThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } }); thread1.start(); thread1.join(); } } // https://stackoverflow.com/questions/1.. 2022. 7. 24.
[JavaScript] 웹 스크래핑(Web Scraping) 예제(2) axios 와 cheerio 를 활용하여 인프런 사이트를 크롤링하는 예제다. 코드 작성 이전에 코드를 작성할 폴더를 열고, vscode 의 터미널에 다음을 입력한다. npm init -y npm install axios cheerio 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 const axios = require("axios"); const cheerio = require("cheerio"); const getHTML = async(keyword) => { try { return await axios.get("https://www.inflearn.com/courses?s=" + e.. 2022. 7. 6.
[JavaScript] 웹 스크래핑(Web Scraping) 예제(1) Javascript 의 puppeteer 라이브러리를 활용하여 크롤링하는 기본 예제다. 여기선 puppeteer 를 사용하였다. 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 // const webcrw = require('파일 경로') // webcrw 에서 exports 에 들어간 가 // require 함수의 output으로 나옴 // require 의 전체 구성 코드 /* const require = function(src) { let foleAsStr = readFile(src); let module.exports = {};.. 2022. 7. 2.