Booky / Python

Source ยป

Gather random book data by scraping Goodreads.

Thanks to Code Review user MrGrj for the suggested code improvements (present in v2 onward) and to user alecxe for the suggested code improvements (present in v5).

$ python3 -h
usage: [-h] [-v {0,1,2,3}] [-mr MIN_RATING] filepath

Gather random book data from Goodreads and append it to a file in CSV format, until the program is manually closed or until a connection issue. I recommend having the CSV header: Title,Pages,Rating.

positional arguments:
  filepath              output file, only supports FULL path (no tilde, etc.)

optional arguments:
  -h, --help            show this help message and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        specify verbosity level, default = 2
                        0 = no output
                        1 = continually print line count after appending to file
                        2 = after keyboard interrupt, print count of lines added since program start and program run time
                        3 = both verbosity options 1 and 2
  -mr MIN_RATING, --min-rating MIN_RATING
                        specify the minimum accepted rating, default = 30