Skip to content

How to extract items of a list into a []struct? #15

Open
@TLINDEN

Description

@TLINDEN

Howdy,

I'd need you help again. I'm trying to scrape an amazon wishlist. There are several items per list which I'm trying to put into a slice of Items:

type Wishlist struct {
	Name  string     `goquery:"#profile-list-name,text"`
	Items []Wishitem `goquery:"#content-right,[html]"`
}

type Wishitem struct {
	Product string `goquery:"h2.a-size-base"`
	Price   string `goquery:".a-price .a-offscreen"`
	Link    string `goquery:"h2.a-size-base a,[href]"`
}

While this does extract something, it just creates 1 Wishitem containing ALL matches of the selectors, e.g.:

        items:
            - product: "Cello C1624F 16\" Full HD LED TV Integrierter DVD-Player Triple Tuner DVB-T/T2-C-S/S2 HDMI USB 230V „Pitch Perfect Sound“ für EIN einzigartiges Klangerlebnis\n                        \n                \n            \n        \n        \n    \n\n    \n        \n            \n            \n            \n            \n                \n                \n                    \n                            Cello C1620FS 16\" (41 cm Diagonale) Full HD LED TV mit eingebautem DVD Player DVBT2 S2 Triple Tuner, Schwarz\n"
              price: 199,99 €169,99
              link: ***

I'd expect it to create multiple Wishlist items for every entry on the web page.

Do you have any idea what might be wrong here?

Thanks in advance,
Tom

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions