-
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.
LANTERN-629-Adding humana web scraper
- Loading branch information
1 parent
ccc02bb
commit f196349
Showing
2 changed files
with
45 additions
and
3 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
42 changes: 42 additions & 0 deletions
42
endpointmanager/pkg/chplendpointquerier/humanaurlwebscraper.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,42 @@ | ||
package chplendpointquerier | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" | ||
log "github.com/sirupsen/logrus" | ||
"fmt" | ||
) | ||
|
||
func HumanaURLWebscraper(CHPLURL string, fileToWriteTo string) { | ||
|
||
fmt.Print("Running") | ||
|
||
var lanternEntryList []LanternEntry | ||
var endpointEntryList EndpointList | ||
|
||
doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "p") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
doc.Find("p").Each(func(index int, pElement *goquery.Selection) { | ||
pElement.Find("label").Each(func(index int, labelElement *goquery.Selection){ | ||
if (strings.Contains(labelElement.Text(), "https")){ | ||
url := labelElement.Text() | ||
url = strings.TrimSuffix(url, "/Patient") | ||
var entry LanternEntry | ||
entry.URL = url | ||
lanternEntryList = append(lanternEntryList, entry) | ||
} | ||
}) | ||
}) | ||
|
||
endpointEntryList.Endpoints = lanternEntryList | ||
|
||
err = WriteCHPLFile(endpointEntryList, fileToWriteTo) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
} |