본문 바로가기

Example28

[Rust] Scraping : Naver 메인 페이지 예제 (60일차) # Cargo.toml # ... 중략 [dependencies] reqwest = { version = "0.11.14", features = ["blocking"] } scraper = "0.14.0" // src\main.rs use reqwest::blocking::Client; use scraper::{Html, Selector}; fn main() -> Result { // Create an HTTP client let client = Client::new(); // Make a GET request to the homepage of www.naver.com let res = client.get("https://www.naver.com").send()?; // Extract the HTML r.. 2023. 2. 20.
[Rust] Scraping 예제 (59일차) // cargo add select use select::document::Document; use select::predicate::Name; fn main() { let html = "Hello, world!"; let document = Document::from(html); let h1 = document.find(Name("h1")).next().unwrap(); println!("{}", h1.text()); } // cargo add scraper use scraper::{Html, Selector}; fn main() { let html = "Hello, World!"; let document = Html::parse_document(html); let selector = Selector:.. 2023. 2. 19.
[Rust] Variable : Python 코드 비교 예제 (58일차) [Python] if __name__ == '__main__': x = 1; print(x); # bind x again shadows old one from above x = 'i'; print(x) # declare, init something = None; x = 5; print("x, something", x, something); something = x * 5; print("x, something", x, something); # mutability y = 0; y = y * 2 + x; print(y); BLAH = 42; # only const by convention y *= BLAH; [Rust] fn main() { let x = 1; println!("x: {}", x); // bi.. 2023. 2. 18.
[Rust] Web Spider 예제 (57일차) # Cargo.toml # ... 중략 [dependencies] spider = "1.18.9" tokio = { version = "1.25.0", features = ["full"] } // src/main.rs extern crate spider; use spider::website::Website; use spider::tokio; #[tokio::main] async fn main() { let url = "https://choosealicense.com"; let mut website: Website = Website::new(&url); website.crawl().await; for page in website.get_pages() { println!("- {}", page.get_url.. 2023. 2. 12.