scrape

package
v0.0.0-...-f20cc06 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessProblemSource

func ProcessProblemSource(s string) string

function to clean out some of the BS people perform on C&P titles

func ProcessTags

func ProcessTags(s string) string

func RemoveHtmlBS

func RemoveHtmlBS(s string) string

Helper function that eliminates completely useless HTML tags in titles and whatnot.

Types

type CategoryResponse

type CategoryResponse struct {
	Response struct {
		Category *struct {
			CategoryId int    `json:"category_id"`
			Name       string `json:"category_name"`
			Items      []Post `json:"items"`
		} `json:"category"`
	} `json:"response"`
}

func (*CategoryResponse) ToProblems

func (resp *CategoryResponse) ToProblems(f *ForumSession) []Problem

type Contest

type Contest struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type ContestList

type ContestList map[string][]Contest

key is general category (e.g. olympiad, USA contests, etc)

type ErrorResponse

type ErrorResponse struct {
	Code    string `json:"error_code,omitempty"`
	Message string `json:"error_msg,omitempty"`
}

type ForumSession

type ForumSession struct {
	SessionId string `json:"id"`
	UserId    int    `json:"user_id"`
	Username  string `json:"username"`
	LoggedIn  bool   `json:"logged_in"`
	Role      string `json:"role"`
	Sid       string `json:",omitempty"`
}

func InitForumSession

func InitForumSession() ForumSession

func (*ForumSession) GetCategoryItems

func (f *ForumSession) GetCategoryItems(id int) (*CategoryResponse, error)

func (*ForumSession) GetTopic

func (f *ForumSession) GetTopic(id int) (*TopicResponse, error)

func (*ForumSession) InitRequest

func (f *ForumSession) InitRequest(body_input url.Values) *http.Request

func (*ForumSession) ScrapeForumList

func (session *ForumSession) ScrapeForumList(contests []int) []Problem

type Meta

type Meta struct {
	Contests     ContestList `json:"contestlist"`
	ProblemCount int         `json:"problemcount"`
	Date         time.Time   `json:"date"`
}

type Post

type Post struct {
	PostId   int    `json:"item_id"`
	Title    string `json:"item_text"`
	Type     string `json:"item_type"`
	PostData struct {
		TopicId    int    `json:"topic_id"`
		PostId     int    `json:"post_id"`
		CategoryId int    `json:"category_id"`
		Rendered   string `json:"post_rendered"`
		Canonical  string `json:"post_canonical"`
	} `json:"post_data"`
}

type Problem

type Problem struct {
	Url        string `json:"url"`
	Source     string `json:"source"`
	Statement  string `json:"statement"`
	Rendered   string `json:"rendered"`
	Solution   string `json:"solution"`
	Categories string `json:"categories"`
}

type ScrapeResult

type ScrapeResult struct {
	Meta     Meta      `json:"meta"`
	Problems []Problem `json:"problems"`
}

func ScrapeForumCategories

func ScrapeForumCategories(contestlist ContestList) ScrapeResult

type TopicResponse

type TopicResponse struct {
	Response struct {
		Topic *struct {
			Tags []struct {
				Id   int    `json:"tag_id"`
				Text string `json:"tag_text"`
			} `json:"tags"`
		} `json:"topic"`
	} `json:"response"`
}

Jump to

Keyboard shortcuts

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