mirror of
https://github.com/gosom/google-maps-scraper.git
synced 2026-09-19 07:27:12 +08:00
Fall back to [88][0] for place status when [34][4][4] is empty (#304)
Google Maps place blobs stopped populating the human-readable status at
darray[34][4][4] (~July 2026); permanently-closed places now only carry
a machine enum ("CLOSED") at darray[88][0]. Without the fallback,
closed places scrape with an empty status and are indistinguishable
from open ones.
Old blobs still populate [34][4][4], so it stays the primary source and
the existing raw.json fixture is unaffected.
This commit is contained in:
@@ -419,6 +419,10 @@ func EntryFromJSON(raw []byte, reviewCountOnly ...bool) (entry Entry, err error)
|
||||
entry.Longtitude = getNthElementAndCast[float64](darray, 9, 3)
|
||||
entry.Cid = getNthElementAndCast[string](jd, 25, 3, 0, 13, 0, 0, 1)
|
||||
entry.Status = getNthElementAndCast[string](darray, 34, 4, 4)
|
||||
if entry.Status == "" {
|
||||
// [34][4][4] went dead ~2026-07; closed-state enum now at [88][0] ("CLOSED" / null)
|
||||
entry.Status = getNthElementAndCast[string](darray, 88, 0)
|
||||
}
|
||||
entry.Description = getNthElementAndCast[string](darray, 32, 1, 1)
|
||||
entry.ReviewsLink = getNthElementAndCast[string](darray, 4, 3, 0)
|
||||
entry.Thumbnail = getNthElementAndCast[string](darray, 72, 0, 1, 6, 0)
|
||||
|
||||
@@ -312,3 +312,17 @@ func Test_EntryFromJsonC(t *testing.T) {
|
||||
fmt.Printf("%+v\n", entry)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_EntryFromJSONStatusFallback(t *testing.T) {
|
||||
// Places where [34][4][4] is absent carry the closed-state enum at [88][0].
|
||||
darray := make([]any, 89)
|
||||
darray[88] = []any{"CLOSED"}
|
||||
jd := []any{nil, nil, nil, nil, nil, nil, darray}
|
||||
|
||||
raw, err := json.Marshal(jd)
|
||||
require.NoError(t, err)
|
||||
|
||||
entry, err := gmaps.EntryFromJSON(raw)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "CLOSED", entry.Status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user