Lanark is a PHP library for pulling data from the Glasgow Libraries catalogue.
It uses headless Chrome to scrape the library's Arena website (https://libcat.csglasgow.org/) and provides a (very very) simple interface to work with it programmatically.
- PHP 7+
- Composer
- Chrome, installed on the server (see the Chrome-PHP docs)
composer require abigegg/lanark
use ABigEgg\Lanark;
$client = new Lanark\Client();
// grab an item by its ISBN
$book = $client->getItemByISBN('9781787300521');
var_dump( $book );
// object(Lanark\Item)#21 (5) {
// ["title"]=>
// string(30) "Orwell on truth, George Orwell"
// ["author"]=>
// string(25) "Orwell, George, 1903-1950"
// ["isbn"]=>
// string(13) "9781787300521"
// ["availability_count":protected]=>
// NULL
// ["year"]=>
// string(4) "2017"
// }
use ABigEgg\Lanark;
$client = new Lanark\Client();
// search for some items by keyword
$books = $client->search('hitchhikers guide');
var_dump( $books );
// array(10) {
// [0]=>
// object(ABigEgg\Lanark\Item)#148 (6) {
// ["title"]=>
// string(51) "The hitchhiker's guide to the Galaxy, Douglas Adams"
// ["author"]=>
// string(26) "Adams, Douglas, 1952-2001,"
// ["isbn"]=>
// string(13) "9781509808311"
// ["availability_count":protected]=>
// NULL
// ["year"]=>
// string(4) "2016"
// ["item_page_url"]=>
// NULL
// }
// [1]=>
// object(ABigEgg\Lanark\Item)#247 (6) {
// ["title"]=>
// string(52) "The hitch-hiker's guide to the Bible, Colin Sinclair"
// ["author"]=>
// string(15) "Sinclair, Colin"
// ["isbn"]=>
// string(13) "9781854248541"
// ["availability_count":protected]=>
// NULL
// ["year"]=>
// string(4) "2008"
// ["item_page_url"]=>
// NULL
// }
// }
// ...
use ABigEgg\Lanark;
$client = new Lanark\Client();
$book = $client->getItemByISBN("9781787300521");
var_dump( $book->getAvailability() );
// int(2)
- Add keyword search with
$client->search( 'Keywords' )
- Pull in availability information just-in-time, to avoid unnecessary requests
- Refactoring
- Replace Goutte with Chrome driver, now book availability information works!
- Initial commit
- Search
Search by book title and author (keywords)- Search by book year of publication
- Search by book genre
- Books
Show if book currently available for loan,and from which libraries- Get summary and thumbnail from Google Books, if available
- (If authenticated) reserve a book to borrow it
- Borrowing
- Authenticate with Glasgow Libraries user ID and PIN
- Get a list of your current reservations, and when they are due back
Licensed under the The MIT License