Code Monkey home page Code Monkey logo

goodquotes's Introduction

๐Ÿ“š GoodQuotes ๐Ÿ“š

A Go package for scraping quotes from Goodreads.

Installation

To install GoodQuotes, you can use go get. Run the following command:

go get -u github.com/Mixtre/goodquotes

Usage

Scraping Quotes

You can use the Quotes function to scrape quotes for a specific query.

package main

import (
	"fmt"

	"github.com/Mixtre/goodquotes"
)

func main() {
	// Example: Scraping quotes for a specific query with default page (first page)
	query := "inspiration"
	data := goodquotes.Quotes(query, 0)

	// Printing the scraped data
	for i, quote := range data.Quotes {
		fmt.Println("Quote", i+1, ":")
		fmt.Println("Text:", quote.TextQuote)
		fmt.Println("Author:", quote.Author)
		fmt.Println("Tags:", quote.Tags)
		fmt.Println("Likes:", quote.Likes)
		fmt.Println()
	}
}

Checking for More Pages

You can check if there are more pages available for a query by examining the data.Pages field. If there are additional pages, you can make subsequent requests to scrape quotes from those pages.

package main

import (
	"fmt"

	"github.com/Mixtre/goodquotes"
)

func main() {
	// Example: Checking for more pages and scraping quotes from additional pages
	query := "inspiration"
	data := goodquotes.Quotes(query, 0)

	fmt.Println("Total Pages: ",data.Pages)

	// Checking if there are more pages
	if data.Pages > 1 {
		// Scraping quotes from page 2
		page := 2
		data = goodquotes.Quotes(query, page)

		// Printing the scraped data from page 2
		for i, quote := range data.Quotes {
			fmt.Println("Quote", i+1, ":")
			fmt.Println("Text:", quote.TextQuote)
			fmt.Println("Author:", quote.Author)
			fmt.Println("Tags:", quote.Tags)
			fmt.Println("Likes:", quote.Likes)
			fmt.Println()
		}
	} else {
		fmt.Println("No more pages available.")
	}
}

goodquotes's People

Contributors

mixtre avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.