Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/itz-fork/vrawler

Helper functions for web scraping in V (vlang)
https://github.com/itz-fork/vrawler

v vlang vlang-module web-scraping

Last synced: about 1 month ago
JSON representation

Helper functions for web scraping in V (vlang)

Awesome Lists containing this project

README

        

# Vrawler
Some helper functions that I use to scrape websites

### Retrive by selectors
Used to retrive html elements using css selectors

- Function: `from_selector`
- Arguments:
- `hdoc`: html document as a string (if parsed convert to str with `parsed.str()`)
- `selectors`: string of css selectors (Ex: `#myid > p > a:nth-child(1)`)

Example

```html

Test file


Google
V lang

```

```v
import vrawler

fn main() {
// Suppose this index.html == above html
html_str := read_file('/home/scraped/mysite/index.html')
spn := vrawler.from_selector(html_str, '#mydiv > a:nth-child(2) > span')
println(spn)
}

// stdout
// [V]
```