mirror of
https://github.com/gosom/google-maps-scraper.git
synced 2026-09-19 07:27:12 +08:00
Merge pull request #39 from iamsad5566/main
fix: fix null comments and prices
This commit is contained in:
+16
-11
@@ -341,28 +341,33 @@ func EntryFromJSON(raw []byte) (entry Entry, err error) {
|
||||
5: int(getNthElementAndCast[float64](darray, 175, 3, 4)),
|
||||
}
|
||||
|
||||
reviewsI := getNthElementAndCast[[]any](darray, 52, 0)
|
||||
|
||||
reviewsI := getNthElementAndCast[[]any](darray, 175, 9, 0, 0)
|
||||
for i := range reviewsI {
|
||||
el := getNthElementAndCast[[]any](reviewsI, i)
|
||||
el := getNthElementAndCast[[]any](reviewsI, i, 0)
|
||||
price := getNthElementAndCast[any](el, 2, 6, 2, 2, 0, 0, 1)
|
||||
if price != nil {
|
||||
entry.PriceRange = price.(string)
|
||||
}
|
||||
|
||||
time := getNthElementAndCast[[]any](el, 2, 2, 0, 1, 21, 6, 7)
|
||||
review := Review{
|
||||
Name: getNthElementAndCast[string](el, 0, 1),
|
||||
ProfilePicture: getNthElementAndCast[string](el, 0, 2),
|
||||
When: getNthElementAndCast[string](el, 1),
|
||||
Rating: int(getNthElementAndCast[float64](el, 4)),
|
||||
Description: getNthElementAndCast[string](el, 3),
|
||||
Name: getNthElementAndCast[string](el, 1, 4, 0, 4),
|
||||
ProfilePicture: getNthElementAndCast[string](el, 1, 4, 0, 3),
|
||||
When: fmt.Sprintf("%v-%v-%v", time[0], time[1], time[2]),
|
||||
Rating: int(getNthElementAndCast[float64](el, 2, 0, 0)),
|
||||
Description: getNthElementAndCast[string](el, 2, 15, 0, 0),
|
||||
}
|
||||
|
||||
if review.Name == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
optsI := getNthElementAndCast[[]any](el, 14)
|
||||
optsI := getNthElementAndCast[[]any](el, 2, 2, 0, 1, 21, 7)
|
||||
|
||||
for j := range optsI {
|
||||
val := getNthElementAndCast[string](optsI, j, 6, 0)
|
||||
val := getNthElementAndCast[string](optsI, j)
|
||||
if val != "" {
|
||||
review.Images = append(review.Images, val)
|
||||
review.Images = append(review.Images, val[2:])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user