scraper

package
v0.0.0-...-60af178 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package scraper retrieves recipes from websites containing it in json+ld format. Compatable website include cooking.nytimes.com, seriouseats.com

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchAndTransform

func FetchAndTransform(ctx context.Context, addr string, ingredientToId func(ctx context.Context, name string, kind string) (string, error)) (*api.RecipeWrapper, error)

FetchAndTransform returns a recipe.

Types

type Recipe

type Recipe struct {
	Context         string      `json:"@context"`
	Type            string      `json:"@type"`
	Name            string      `json:"name"`
	DatePublished   string      `json:"datePublished,omitempty"`
	DateModified    string      `json:"dateModified,omitempty"`
	Description     string      `json:"description"`
	Image           interface{} `json:"image"`
	AggregateRating struct {
		Type        string      `json:"@type"`
		RatingValue interface{} `json:"ratingValue"`
		RatingCount interface{} `json:"ratingCount"`
	} `json:"aggregateRating"`
	RecipeCategory     interface{} `json:"recipeCategory"`
	RecipeYield        string      `json:"recipeYield"`
	RecipeIngredient   []string    `json:"recipeIngredient"`
	RecipeInstructions []struct {
		Type string `json:"@type"`
		Text string `json:"text"`
	} `json:"recipeInstructions"`
	Author struct {
		Type        string   `json:"@type"`
		Name        string   `json:"name"`
		JobTitle    string   `json:"jobTitle"`
		SameAs      []string `json:"sameAs"`
		Description string   `json:"description"`
		URL         string   `json:"url"`
	} `json:"author"`
	Keywords      string `json:"keywords"`
	TotalTime     string `json:"totalTime,omitempty"`
	RecipeCuisine string `json:"recipeCuisine,omitempty"`
	Nutrition     struct {
		Context               string      `json:"@context"`
		Type                  string      `json:"@type"`
		Calories              int         `json:"calories"`
		UnsaturatedFatContent string      `json:"unsaturatedFatContent"`
		CarbohydrateContent   string      `json:"carbohydrateContent"`
		CholesterolContent    interface{} `json:"cholesterolContent"`
		FatContent            string      `json:"fatContent"`
		FiberContent          string      `json:"fiberContent"`
		ProteinContent        string      `json:"proteinContent"`
		SaturatedFatContent   string      `json:"saturatedFatContent"`
		SodiumContent         string      `json:"sodiumContent"`
		SugarContent          string      `json:"sugarContent"`
		TransFatContent       string      `json:"transFatContent"`
	} `json:"nutrition,omitempty"`
	Video struct {
		Context      string    `json:"@context"`
		Type         string    `json:"@type"`
		Name         string    `json:"name"`
		Description  string    `json:"description"`
		ThumbnailURL string    `json:"thumbnailUrl"`
		UploadDate   time.Time `json:"uploadDate"`
		Duration     string    `json:"duration"`
	} `json:"video,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL