Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support english website #2

Open
Akenaide opened this issue Dec 9, 2022 · 1 comment
Open

Support english website #2

Akenaide opened this issue Dec 9, 2022 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@Akenaide
Copy link
Owner

Akenaide commented Dec 9, 2022

https://en.ws-tcg.com

@Akenaide Akenaide added the enhancement New feature or request label Dec 9, 2022
@Akenaide Akenaide added this to the v4.0.0 milestone Feb 14, 2023
@Akenaide
Copy link
Owner Author

Akenaide commented May 15, 2023

	// Extract information from the HTML using CSS selectors
	doc.Find("tbody tr").Each(func(i int, s *goquery.Selection) {
		cardTitle := s.Find("a span.highlight_target").First().Text()
		cardNo := s.Find("a span.highlight_target").Last().Text()
		cardType := s.Find(".unit:contains('Card Type')").Text()
		level := s.Find(".unit:contains('Level')").Text()
		color := s.Find(".unit:contains('Color') img").AttrOr("src", "")
		power := s.Find(".unit:contains('Power')").Text()
		rarity := s.Find(".unit:contains('Rarity')").Text()
		flavorText := s.Find(".unit:contains('Flavor Text') span").Text()
		trigger := s.Find(".unit:contains('Trigger') img").Map(func(_ int, sel *goquery.Selection) string {
			return strings.TrimPrefix(strings.TrimSuffix(sel.AttrOr("src", ""), ".gif"), "../partimages/")
		})


		// Print the extracted information
		fmt.Printf("Card Title: %s\n", strings.TrimSpace(cardTitle))
		fmt.Printf("Card No: %s\n", strings.TrimSpace(cardNo))
		fmt.Printf("Card Type: %s\n", strings.TrimSpace(cardType))
		fmt.Printf("Level: %s\n", strings.TrimSpace(level))
		fmt.Printf("Color: %s\n", strings.TrimPrefix(strings.TrimSuffix(color, ".gif"), "../partimages/"))
		fmt.Printf("Power: %s\n", strings.TrimSpace(power))
		fmt.Printf("Rarity: %s\n", strings.TrimSpace(rarity))
		fmt.Printf("Flavor Text: %s\n", strings.TrimSpace(flavorText))
		fmt.Println("--------------------------------------------------")
	})

Try this, it's generated by chatgpt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant