1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Merge pull request #83 from Yethal/main

Added webscraping example
This commit is contained in:
Darren Schroeder 2021-08-04 16:07:08 -05:00 committed by GitHub
commit f23f784f57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

5
webscraping/README.md Normal file
View file

@ -0,0 +1,5 @@
# Web scraping
### Definition
This folder includes examples of using nushell to scrape server side rendered websites

9
webscraping/scraping.nu Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env nu
let baseurl = 'https://www.schiit.co.uk/'
let pages = [headphone-amps dacs schiit-gaming-products power-amplifiers preamps upgrades accessories-cables schiit%20graded%20stock]
$pages|each {
let product = $it
fetch (build-string $baseurl $product)|selector 'div.caption' -a|each {
echo [[($it|selector 'h5'|str trim)]; [(echo $it|selector 'p.stock')]]|pivot $product availability
}
}