-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a new webscraper and test file for Zoobook Systems
- Loading branch information
1 parent
9a34eb4
commit aa57981
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
endpointmanager/pkg/chplendpointquerier/zoobooksystemswebscraper.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package chplendpointquerier | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func ZoobooksystemsWebscraper(CHPLURL string, fileToWriteTo string) { | ||
|
||
var lanternEntryList []LanternEntry | ||
var endpointEntryList EndpointList | ||
doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, ".col-lg-6.text-secondary.fw-bold") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
inProduction := false | ||
|
||
doc.Find(".col-lg-6").Each(func(index int, divhtml *goquery.Selection) { | ||
if divhtml.Text() == "PRODUCTION" { | ||
inProduction = true | ||
} | ||
|
||
if inProduction { | ||
divhtml.Find("a").Each(func(indextr int, ahtml *goquery.Selection) { | ||
if strings.Contains(ahtml.Text(), "https") && !strings.Contains(ahtml.Text(), "oauth") { | ||
var entry LanternEntry | ||
|
||
entryURL := strings.TrimSpace(ahtml.Text()) | ||
entry.URL = entryURL | ||
|
||
lanternEntryList = append(lanternEntryList, entry) | ||
|
||
endpointEntryList.Endpoints = lanternEntryList | ||
|
||
err = WriteCHPLFile(endpointEntryList, fileToWriteTo) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
return | ||
} | ||
}) | ||
} | ||
}) | ||
} |