Select or create shop before parsing
A shop map was created to group URLs by shops and process them in order. Now that we have Amazon and each URL can be parsed independently, there is no need to group them anymore. Moreover, shops were passed as an argument to the handleProducts function. Shop name can be deduced by the parser itself. The parser has a reference to the database. The parser now select or create the shop before parsing products. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
5f69b8435b
commit
ab5abcd171
4 changed files with 34 additions and 42 deletions
|
@ -28,6 +28,11 @@ func (p *URLParser) String() string {
|
|||
return fmt.Sprintf("URLParser<%s>", p.url)
|
||||
}
|
||||
|
||||
// ShopName returns shop name from URL
|
||||
func (p *URLParser) ShopName() (string, error) {
|
||||
return ExtractShopName(p.url)
|
||||
}
|
||||
|
||||
// NewURLParser to create a new URLParser instance
|
||||
func NewURLParser(url string, browserAddress string, includeRegex string, excludeRegex string) (*URLParser, error) {
|
||||
var err error
|
||||
|
|
Reference in a new issue