parsers

package
v0.0.0-...-b788d29 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	Type        string    `json:"@type"`
	Text        string    `json:"text"`
	Author      Author    `json:"author"`
	Datecreated time.Time `json:"dateCreated"`
	Upvotecount int       `json:"upvoteCount"`
}

type Author

type Author struct {
	Type string `json:"@type"`
	Name string `json:"name"`

} // Sadly, the Author struct as returned in the page-embedded version does not contain unique author IDs

type GenericForumParser

type GenericForumParser struct {
	// some space for parser specific data here
	Config GenericParserConfig
}

func (*GenericForumParser) ParseResponse

func (fp *GenericForumParser) ParseResponse(body io.Reader, header http.Header, uri string) ([]forum.Post, error)

type GenericParserConfig

type GenericParserConfig struct {
	PostSelector string
	UserSelector string
	MsgSelector  string
	HdrSelector  string
}

type LeagueForumParser

type LeagueForumParser struct {
}

func (*LeagueForumParser) ParseResponse

func (fp *LeagueForumParser) ParseResponse(body io.Reader, header http.Header, uri string) ([]forum.Post, error)

type Mainentity

type Mainentity struct {
	Type            string    `json:"@type"`
	Name            string    `json:"name"`
	Text            string    `json:"text"`
	Answercount     int       `json:"answerCount"`
	Datecreated     time.Time `json:"dateCreated"`
	Author          Author    `json:"author"`
	Acceptedanswer  Answer    `json:"acceptedAnswer"`
	Suggestedanswer []Answer  `json:"suggestedAnswer"`
}

type PagePayload

type PagePayload struct {
	Context    string     `json:"@context"`
	Type       string     `json:"@type"`
	Mainentity Mainentity `json:"mainEntity"`
}

PagePayload is the structure of the embedded json+ld data when an answer page has <10 answers

type QAPagePayload

type QAPagePayload struct {
	Qid         string `json:"qid"`
	AnswerCount int    `json:"answerCount"`
	Start       int    `json:"start"`
	Count       int    `json:"count"`
	SortType    string `json:"sortType"`
	Lang        string `json:"lang"`
	Answers     []struct {
		Qid              string      `json:"qid"`
		ID               string      `json:"id"`
		Text             string      `json:"text"`
		AttachedImageURL interface{} `json:"attachedImageUrl"` // todo find the right types
		AttachedImageID  interface{} `json:"attachedImageId"`  // todo find the right types
		Reference        interface{} `json:"reference"`        // todo find the right types
		Answerer         struct {
			Euid     string `json:"euid"`
			Kid      string `json:"kid"`
			Nickname string `json:"nickname"`
			ImageURL string `json:"imageUrl"`
			Level    int    `json:"level"`
		} `json:"answerer"`
		IsBestAnswer       bool      `json:"isBestAnswer"`
		ThumbsDown         int       `json:"thumbsDown"`
		ThumbsUp           int       `json:"thumbsUp"`
		IsAnonymous        bool      `json:"isAnonymous"`
		CommentCount       int       `json:"commentCount"`
		CreatedTime        time.Time `json:"createdTime"`
		UserAnswerRelation struct {
			HasFlagged          bool `json:"hasFlagged"`
			CanFlag             bool `json:"canFlag"`
			CanVote             bool `json:"canVote"`
			CanChooseBestAnswer bool `json:"canChooseBestAnswer"`
			HasVoted            bool `json:"hasVoted"`
			IsAuthor            bool `json:"isAuthor"`
			HasCommented        bool `json:"hasCommented"`
			CanComment          bool `json:"canComment"`
		} `json:"userAnswerRelation"`
	} `json:"answers"`
	IsServerFetched bool `json:"isServerFetched"`
}

QAPagePayload is the structure as returned when using the PUT requests to the _reservice_ endpoint

type ServicePayload

type ServicePayload struct {
	Type      string `json:"type"`
	Reservice struct {
		Name           string `json:"name"`
		Start          string `json:"start"`
		State          string `json:"state"`
		PreviousAction struct {
			KvPayload struct {
				Key            string `json:"key"`
				KvActionPrefix string `json:"kvActionPrefix"`
			} `json:"kvPayload"`
			Payload struct {
				Count    int    `json:"count"`
				Lang     string `json:"lang"`
				Qid      string `json:"qid"`
				SortType string `json:"sortType"`
				Start    int    `json:"start"`
			} `json:"payload"`
			Reservice struct {
				Name  string `json:"name"`
				Start string `json:"start"`
				State string `json:"state"`
			} `json:"reservice"`
			Type string `json:"type"`
		} `json:"previous_action"`
	} `json:"reservice"`
	Payload json.RawMessage `json:"payload"`
	Error   bool            `json:"error"`
}

ServicePayload is the structure as seen using the PUT requests to the _reservice_ endpoint

type YahooAnswersParser

type YahooAnswersParser struct {
}

func (*YahooAnswersParser) ParseResponse

func (fp *YahooAnswersParser) ParseResponse(body io.Reader, header http.Header, uri string) ([]forum.Post, error)

Jump to

Keyboard shortcuts

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