Bookmeter Scraper Build Status

A library for scraping Bookmeter.

Japanese README is here.

Installation

Add this line to your application's Gemfile:

gem 'bookmeter_scraper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bookmeter_scraper

Usage

Add this line to your code before using this library:

require 'bookmeter_scraper'

Log in

You need to log in Bookmeter to get books and followings / followers information by Bookmeter.log_in or Bookmeter#log_in.

There are 2 ways to input authentication information:

  1. Passing as arguments
  2. Writing out to config.yml

1. Passing as arguments

You can log in Bookmeter by passing mail address and password to Bookmeter.log_in:

bookmeter = BookmeterScraper::Bookmeter.('[email protected]', 'your_password')
bookmeter.logged_in?    # true

Bookmeter#log_in is also available:

bookmeter = BookmeterScraper::Bookmeter.new
bookmeter.('[email protected]', 'password')

2. Writing out to config.yml

Create config.yml as followings and save it to the same directory as your Ruby script:

mail: [email protected]
password: your_password

Now you can log in Bookmeter by calling Bookmeter.log_in or Bookmeter#log_in with no arguments:

bookmeter = BookmeterScraper::Bookmeter.
bookmeter.logged_in?    # true

Get books information

You can get books information:

  • read books
  • reading books
  • tsundoku (stockpile)
  • wish list

You need to log in Bookmeter in advance to get these information.

Read books

You can get read books information by Bookmeter#read_books:

books = bookmeter.read_books        # get read books of the logged in user
bookmeter.read_books('01010101')    # get read books of a user specified by ID

Books infomation is an array of Struct which has name and read_dates as attributes. read_dates is an array of finished reading dates (first finished date and reread dates):

books[0].name
books[0].read_dates

To specify year-month for read books, you can use Bookmeter#read_books_in:

books = bookmeter.read_books_in(2016, 1)                # get read books of the logged in user in 2016-01
books = bookmeter.read_books_in(2016, 1, '01010101')    # get read books of a user in 2016-01

Reading books / Tsundoku / Wish list

You can get other books information:

  • Bookmeter#reading_books
  • Bookmeter#tsundoku
  • Bookmeter#wish_list
books = bookmeter.reading_books
books[0].name
books[0].read_dates    # this array is empty

bookmeter.tsundoku
bookmeter.wish_list

Get followings users / followers information

You can get following users (followings) and followers information by Bookmeter#followings and Bookmeter#followers:

following_users = bookmeter.followings
followers = bookmeter.followers

You need to log in Bookmeter in advance to get these information.

Users information is an array of Struct which has name and id as attributes.

following_users[0].name
following_users[0].id
followers[0].name
followers[0].id

Notice

Bookmeter#followings and Bookmeter#followers have not supported paginated followings / followers pages yet.

Get user profile

You can get a user profile by Bookmeter#profile:

bookmeter = BookmeterScraper::Bookmeter.new
user_id = '000000'
profile = bookmeter.profile(user_id)    # You can specify arbitrary user ID

You do not need to log in to get user profiles. Profile information is Struct which has these attributes:

profile.name
profile.gender
profile.age
profile.blood_type
profile.job
profile.address
profile.url
profile.description
profile.first_day
profile.elapsed_days
profile.read_books_count
profile.read_pages_count
profile.reviews_count
profile.bookshelfs_count

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kymmt90/bookmeter_scraper.

License

The gem is available as open source under the terms of the MIT License.