gmaps

package
v0.0.0-...-b8d96e6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkippedOutOfBounds = fmt.Errorf("skipped: place is outside the defined bounds")

ErrSkippedOutOfBounds is returned when a place is dropped because it's outside the defined GeoJSON boundary.

Functions

func FetchReviewsWithFallback

func FetchReviewsWithFallback(ctx context.Context, params fetchReviewsParams) (FetchReviewsResponse, []DOMReview, error)

FetchReviewsWithFallback attempts RPC-based extraction first, then falls back to DOM

Types

type About

type About struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Options []Option `json:"options"`
}

type Address

type Address struct {
	Borough    string `json:"borough"`
	Street     string `json:"street"`
	City       string `json:"city"`
	PostalCode string `json:"postal_code"`
	State      string `json:"state"`
	Country    string `json:"country"`
}

type DOMReview

type DOMReview struct {
	AuthorName              string
	AuthorURL               string
	ProfilePicture          string
	Rating                  int
	RelativeTimeDescription string
	Text                    string
	Images                  []string
}

DOMReview represents a review extracted from the DOM

type EmailExtractJob

type EmailExtractJob struct {
	scrapemate.Job

	Entry                   *Entry
	ExitMonitor             exiter.Exiter
	WriterManagedCompletion bool
}

func NewEmailJob

func NewEmailJob(parentID string, entry *Entry, opts ...EmailExtractJobOptions) *EmailExtractJob

func (*EmailExtractJob) Process

func (j *EmailExtractJob) Process(ctx context.Context, resp *scrapemate.Response) (any, []scrapemate.IJob, error)

func (*EmailExtractJob) ProcessOnFetchError

func (j *EmailExtractJob) ProcessOnFetchError() bool

type EmailExtractJobOptions

type EmailExtractJobOptions func(*EmailExtractJob)

func WithEmailJobExitMonitor

func WithEmailJobExitMonitor(exitMonitor exiter.Exiter) EmailExtractJobOptions

func WithEmailJobWriterManagedCompletion

func WithEmailJobWriterManagedCompletion() EmailExtractJobOptions

type Entry

type Entry struct {
	ID         string              `json:"input_id"`
	Link       string              `json:"link"`
	Cid        string              `json:"cid"`
	Title      string              `json:"title"`
	Categories []string            `json:"categories"`
	Category   string              `json:"category"`
	Address    string              `json:"address"`
	OpenHours  map[string][]string `json:"open_hours"`
	// PopularTImes is a map with keys the days of the week
	// and value is a map with key the hour and value the traffic in that time
	PopularTimes        map[string]map[int]int `json:"popular_times"`
	WebSite             string                 `json:"web_site"`
	Phone               string                 `json:"phone"`
	PlusCode            string                 `json:"plus_code"`
	ReviewCount         int                    `json:"review_count"`
	ReviewRating        float64                `json:"review_rating"`
	ReviewsPerRating    map[int]int            `json:"reviews_per_rating"`
	Latitude            float64                `json:"latitude"`
	Longtitude          float64                `json:"longtitude"`
	Status              string                 `json:"status"`
	Description         string                 `json:"description"`
	ReviewsLink         string                 `json:"reviews_link"`
	Thumbnail           string                 `json:"thumbnail"`
	Timezone            string                 `json:"timezone"`
	PriceRange          string                 `json:"price_range"`
	DataID              string                 `json:"data_id"`
	PlaceID             string                 `json:"place_id"`
	Images              []Image                `json:"images"`
	Reservations        []LinkSource           `json:"reservations"`
	OrderOnline         []LinkSource           `json:"order_online"`
	Menu                LinkSource             `json:"menu"`
	Owner               Owner                  `json:"owner"`
	CompleteAddress     Address                `json:"complete_address"`
	About               []About                `json:"about"`
	UserReviews         []Review               `json:"user_reviews"`
	UserReviewsExtended []Review               `json:"user_reviews_extended"`
	Emails              []string               `json:"emails"`
}

func EntryFromJSON

func EntryFromJSON(raw []byte, reviewCountOnly ...bool) (entry Entry, err error)

func ParseSearchResults

func ParseSearchResults(raw []byte) ([]*Entry, error)

func (*Entry) AddExtraReviews

func (e *Entry) AddExtraReviews(pages [][]byte)

func (*Entry) CsvHeaders

func (e *Entry) CsvHeaders() []string

func (*Entry) CsvRow

func (e *Entry) CsvRow() []string

func (*Entry) IsWebsiteValidForEmail

func (e *Entry) IsWebsiteValidForEmail() bool

func (*Entry) Validate

func (e *Entry) Validate() error

type EntryWithDistance

type EntryWithDistance struct {
	Entry    *Entry
	Distance float64
}

type FetchReviewsResponse

type FetchReviewsResponse struct {
	// contains filtered or unexported fields
}

type GmapJob

type GmapJob struct {
	scrapemate.Job

	MaxDepth     int
	LangCode     string
	ExtractEmail bool
	GeoJSON      string // <-- 新增字段

	Deduper                 deduper.Deduper
	ExitMonitor             exiter.Exiter
	ExtractExtraReviews     bool
	WriterManagedCompletion bool
}

func NewGmapJob

func NewGmapJob(
	id, langCode, query string,
	maxDepth int,
	extractEmail bool,
	geoCoordinates string,
	zoom int,
	opts ...GmapJobOptions,
) *GmapJob

func (*GmapJob) BrowserActions

func (j *GmapJob) BrowserActions(ctx context.Context, page scrapemate.BrowserPage) scrapemate.Response

func (*GmapJob) Process

func (j *GmapJob) Process(ctx context.Context, resp *scrapemate.Response) (any, []scrapemate.IJob, error)

func (*GmapJob) ProcessOnFetchError

func (j *GmapJob) ProcessOnFetchError() bool

func (*GmapJob) UseInResults

func (j *GmapJob) UseInResults() bool

type GmapJobOptions

type GmapJobOptions func(*GmapJob)

func WithDeduper

func WithDeduper(d deduper.Deduper) GmapJobOptions

func WithExitMonitor

func WithExitMonitor(e exiter.Exiter) GmapJobOptions

func WithExtraReviews

func WithExtraReviews() GmapJobOptions

func WithGmapJobGeoJSON

func WithGmapJobGeoJSON(geojson string) GmapJobOptions

func WithWriterManagedCompletion

func WithWriterManagedCompletion() GmapJobOptions

type Image

type Image struct {
	Title string `json:"title"`
	Image string `json:"image"`
}

type LinkSource

type LinkSource struct {
	Link   string `json:"link"`
	Source string `json:"source"`
}

type MapLocation

type MapLocation struct {
	Lat     float64
	Lon     float64
	ZoomLvl float64
	Radius  float64
}

type MapSearchParams

type MapSearchParams struct {
	Location  MapLocation
	Query     string
	ViewportW int
	ViewportH int
	Hl        string
	GeoJSON   string // <-- 新增:用于接收前端传来的 GeoJSON 边界数据
}

type Option

type Option struct {
	Name    string `json:"name"`
	Enabled bool   `json:"enabled"`
}

type Owner

type Owner struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Link string `json:"link"`
}

type PlaceJob

type PlaceJob struct {
	scrapemate.Job
	GeoJSON                 string
	UsageInResultststs      bool
	ExtractEmail            bool
	ExitMonitor             exiter.Exiter
	ExtractExtraReviews     bool
	WriterManagedCompletion bool
}

func NewPlaceJob

func NewPlaceJob(parentID, langCode, u string, extractEmail, extraExtraReviews bool, opts ...PlaceJobOptions) *PlaceJob

func (*PlaceJob) BrowserActions

func (j *PlaceJob) BrowserActions(ctx context.Context, page scrapemate.BrowserPage) scrapemate.Response

func (*PlaceJob) Process

func (j *PlaceJob) Process(_ context.Context, resp *scrapemate.Response) (any, []scrapemate.IJob, error)

func (*PlaceJob) ProcessOnFetchError

func (j *PlaceJob) ProcessOnFetchError() bool

========================================== 修复点:修改 ProcessOnFetchError,确保因边界过滤产生的 error 不会被重试 ==========================================

func (*PlaceJob) UseInResults

func (j *PlaceJob) UseInResults() bool

type PlaceJobOptions

type PlaceJobOptions func(*PlaceJob)

func WithPlaceJobExitMonitor

func WithPlaceJobExitMonitor(exitMonitor exiter.Exiter) PlaceJobOptions

func WithPlaceJobGeoJSON

func WithPlaceJobGeoJSON(geojson string) PlaceJobOptions

func WithPlaceJobWriterManagedCompletion

func WithPlaceJobWriterManagedCompletion() PlaceJobOptions

type Review

type Review struct {
	Name           string
	ProfilePicture string
	Rating         int
	Description    string
	Images         []string
	When           string
}

func ConvertDOMReviewsToReviews

func ConvertDOMReviewsToReviews(domReviews []DOMReview) []Review

ConvertDOMReviewsToReviews converts DOMReview slice to Review slice

type SearchJob

type SearchJob struct {
	scrapemate.Job

	ExitMonitor             exiter.Exiter
	WriterManagedCompletion bool
	// contains filtered or unexported fields
}

func NewSearchJob

func NewSearchJob(params *MapSearchParams, opts ...SearchJobOptions) *SearchJob

func (*SearchJob) Process

func (j *SearchJob) Process(_ context.Context, resp *scrapemate.Response) (any, []scrapemate.IJob, error)

func (*SearchJob) ProcessOnFetchError

func (j *SearchJob) ProcessOnFetchError() bool

type SearchJobOptions

type SearchJobOptions func(*SearchJob)

func WithSearchJobExitMonitor

func WithSearchJobExitMonitor(exitMonitor exiter.Exiter) SearchJobOptions

func WithSearchJobWriterManagedCompletion

func WithSearchJobWriterManagedCompletion() SearchJobOptions

Jump to

Keyboard shortcuts

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