Skip to main content

Crate spider_macro

Crate spider_macro 

Source
Expand description

§spider-macro

Procedural macros used by the spider-* workspace.

Right now this crate is intentionally small: it mainly provides scraped_item, the attribute macro used to turn plain structs into item types that fit the crawler and pipeline APIs.

§Dependencies

[dependencies]
spider-macro = "0.1.12"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

§Example

use spider_macro::scraped_item;

#[scraped_item]
struct Article {
    title: String,
    content: String,
}

// `Article` now implements Serialize, Deserialize, Clone, Debug,
// and the ScrapedItem trait expected by the rest of the workspace.

Attribute Macros§

scraped_item
Attribute macro for defining a scraped item type.