Skip to content

Commit

Permalink
"Has visto a" alerts from Guerrero were not "titlelized" their names,…
Browse files Browse the repository at this point in the history
… it was fixed, also custom alerts from Morelos now are scraping the publication date
  • Loading branch information
midir99 committed Jul 24, 2022
1 parent 790ddba commit 94cd4a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func ParseArgs() (*Args, error) {
}

func PrintVersion() {
fmt.Println("rastreadora v0.3.0 ")
fmt.Println("rastreadora v0.3.1")
}

func SelectScraperFuncs(scraper Scraper) (func(*html.Node) []mpp.MissingPersonPoster, func(uint64) string, error) {
Expand Down
2 changes: 1 addition & 1 deletion ws/gro.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func ScrapeGroHasVistoAAlerts(doc *html.Node) []mpp.MissingPersonPoster {
mpps := []mpp.MissingPersonPoster{}
for _, figure := range QueryAll(doc, "figure") {
h4 := Query(figure, "h4")
mpName := h4.FirstChild.Data
mpName := cases.Title(language.LatinAmericanSpanish).String(h4.FirstChild.Data)
missingDate, _ := time.Parse("2006-01-02", h4.LastChild.Data)
postUrl := AttrOr(Query(figure, "a"), "href", "")
if postUrl == "" {
Expand Down
13 changes: 8 additions & 5 deletions ws/mor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ func ParseMorDate(value string) (time.Time, error) {
case "diciembre":
month = time.December
default:
return time.Time{}, fmt.Errorf("unable to parse date %s", value)
return time.Time{}, fmt.Errorf("unable to parse date %s (unknown month: %s)", value, month)
}
day, err := strconv.Atoi(date[DAY_INDEX])
day, err := strconv.Atoi(strings.TrimSpace(strings.Replace(date[DAY_INDEX], ",", "", 1)))
if err != nil {
return time.Time{}, fmt.Errorf("unable to parse date %s", value)
return time.Time{}, fmt.Errorf("unable to parse date %s (invalid day number: %s)", value, date[DAY_INDEX])
}
year, err := strconv.Atoi(date[YEAR_INDEX])
if err != nil {
return time.Time{}, fmt.Errorf("unable to parse date %s", value)
return time.Time{}, fmt.Errorf("unable to parse date %s (invalid year number: %s)", value, date[YEAR_INDEX])
}
return time.Date(year, month, day, 0, 0, 0, 0, time.UTC), nil
}
Expand Down Expand Up @@ -113,7 +113,10 @@ func ScrapeMorCustomAlerts(doc *html.Node) []mpp.MissingPersonPoster {
continue
}
poPostPublicationDate, _ := ParseMorDate(strings.TrimSpace(Query(article, "span").FirstChild.Data))
poPosterUrl, _ := url.Parse(strings.TrimSpace(AttrOr(Query(article, "img"), "src", "")))
posterUrl := strings.TrimSpace(AttrOr(Query(article, "img"), "src", ""))
posterUrl = strings.Replace(posterUrl, "-300x225", "", 1)
posterUrl = strings.Replace(posterUrl, "-300x240", "", 1)
poPosterUrl, _ := url.Parse(posterUrl)
mpps = append(mpps, mpp.MissingPersonPoster{
MpName: mpName,
PoPosterUrl: poPosterUrl,
Expand Down

0 comments on commit 94cd4a9

Please sign in to comment.