Requests2
A Rust library the crate help you quickly request, parse and store data
([Python] BS4 library).
-
Each new requests initializes a cache instance which stores the parsed data in key value pairs
-
When you get an instance of connect, you can call the parser method to parse the data in the form of closure
-
use dbnote macro, write data to a database table
-
set connect database str in
configfile -
find find_all select select_all method supports CSS selectors to parse DOM document
config
postgres=
sqlite=
auto add sqlite_db file to project dir, support sqlite
store data to csv and postgres database, you can use this example code:
// store example
use ;
// change postgres to sqlite same run
// parse code
let data = new;
let client = new;
let rq = client.connect;
rq.free_parse;
Add #[dbnote(table_name = "test_link", driver = "postgres", primary_key="href")] to struct, you can use
write_csv_head() and to_csv put data to a file, table_name as file name.
Use createa_table() you can creata table in postgres , but you must add config file to project. to_db()
put data to the table.
find() find_all() select() select_all() method unified use css selector as first argument.
See the test folder for more details