Created
February 14, 2020 13:14
-
-
Save piEsposito/0177ca63a99de0b6db64c69d71e787a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package crawl_functions | |
import ( | |
"fmt" | |
"strconv" | |
"sync" | |
) | |
func FeedChannel(page_start int, page_nmr int, c chan int, wg *sync.WaitGroup) { | |
/* | |
This is a auxiliary function to feed our channel with page ids for start and end | |
*/ | |
for i := page_start; i < page_nmr; i++ { | |
c <- i | |
} | |
wg.Done() | |
} | |
func CreateLink(idx int) (string, string) { | |
/* | |
This function creates a link for the json using the page id. | |
*/ | |
nmr := strconv.Itoa(idx) | |
path := fmt.Sprintf("%s.json", nmr) | |
link_base_1 := "https://www.webmotors.com.br/api/search/car?url=https://www.webmotors.com.br/carros-usados%%2Festoque%%3Finst%%3Dheader%%3Awebmotors%%3Aheader-deslogado%%3A%%3Acarros-usados-ou-seminovos&actualPage=" | |
link_base_2 := "&displayPerPage=23&order=1&showMenu=true&showCount=true&showBreadCrumb=true&testAB=false&returnUrl=false" | |
link := fmt.Sprintf(link_base_1 + nmr + link_base_2) | |
return link, path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment