-
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.
Merge branch 'main' into LANTERN-771-772-773-webscrapers-and-csvparsers
- Loading branch information
Showing
6 changed files
with
101 additions
and
8 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
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
40 changes: 40 additions & 0 deletions
40
endpointmanager/pkg/chplendpointquerier/ehealthlinewebscraper.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,40 @@ | ||
package chplendpointquerier | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func EhealthlineWebscraper(CHPLURL string, fileToWriteTo string) { | ||
|
||
var lanternEntryList []LanternEntry | ||
var endpointEntryList EndpointList | ||
|
||
ipPattern := `\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?\b` | ||
ipRegex := regexp.MustCompile(ipPattern) | ||
|
||
doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
doc.Find("td:contains('https')").Each(func(index int, item *goquery.Selection) { | ||
if !ipRegex.MatchString(item.Text()) { | ||
var entry LanternEntry | ||
entry.URL = strings.TrimSpace(item.Find("span").Text()) | ||
lanternEntryList = append(lanternEntryList, entry) | ||
} | ||
}) | ||
|
||
endpointEntryList.Endpoints = lanternEntryList | ||
|
||
err = WriteCHPLFile(endpointEntryList, fileToWriteTo) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
endpointmanager/pkg/chplendpointquerier/ezemrxwebscraper.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,38 @@ | ||
package chplendpointquerier | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func EzemrxWebscraper(CHPLURL string, fileToWriteTo string) { | ||
|
||
var lanternEntryList []LanternEntry | ||
var endpointEntryList EndpointList | ||
var entry LanternEntry | ||
|
||
doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "#comp-lb6njyhb") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
divElem := doc.Find("#comp-lb6njyhb").First() | ||
pElem := divElem.Find("p").First() | ||
spanElem := pElem.Find("span").First() | ||
|
||
parts := strings.Split(spanElem.Text(), "\n") | ||
|
||
entry.URL = strings.TrimSpace(parts[1]) | ||
|
||
lanternEntryList = append(lanternEntryList, entry) | ||
|
||
endpointEntryList.Endpoints = lanternEntryList | ||
|
||
err = WriteCHPLFile(endpointEntryList, fileToWriteTo) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
} |
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