hi-imdb-crawler
v0.1.3
Published
A node library to gets Movie and Tv Series info from IMDB and returns collected data as a json
Downloads
1
Readme
IMDB Crawler
A node library to get Movie and Tv Series info from IMDB and returns collected data as a json
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
Nodejs, Npm
Installing
npm i hi-imdb-crawler
Options
Default options
{
'movie': {
'imdb_id': {
'container': "meta[property='pageId']",
'attr' : "content",
'type' : "String"
},
'name': {
'container': ".title_wrapper > h1[itemprop='name']",
'attr': false,
'type': 'String'
},
'directors': {
'container': "span[itemprop='director'] > a > span[itemprop='name']",
'attr': false,
'type': 'String|Array'
},
'creators': {
'container': "span[itemprop='creator'] > a > span[itemprop='name']",
'attr': false,
'type': 'String|Array'
},
'description': {
'container': ".summary_text",
'attr': false,
'type': 'String'
},
'original_title': {
'container': ".originalTitle",
'attr': false,
'type': 'String'
},
'duration': {
'container': ".title_wrapper .subtext time[itemprop='duration']",
'attr': false,
'type': 'String'
},
'rating': {
'container': "span[itemprop='ratingValue']",
'attr': false,
'type': 'String|Float'
},
'image': {
'container': "meta[property='og:image']",
'attr': 'content',
'type': 'Image'
},
'genres': {
'container': "div[itemprop='genre'] a",
'attr': false,
'type': 'String|Array'
},
},
'series': {
'imdb_id': {
'container': "meta[property='pageId']",
'attr' : "content",
'type' : "String"
},
'name': {
'container': ".title_wrapper > h1[itemprop='name']",
'attr': false,
'type': 'String'
},
'creators': {
'container': "span[itemprop='creator'] > a > span[itemprop='name']",
'attr': false,
'type': 'String|Array'
},
'description': {
'container': ".summary_text",
'attr': false,
'type': 'String'
},
'original_title': {
'container': ".originalTitle",
'attr': false,
'type': 'String'
},
'duration': {
'container': ".title_wrapper .subtext time[itemprop='duration']",
'attr': false,
'type': 'String'
},
'rating': {
'container': "span[itemprop='ratingValue']",
'attr': false,
'type': 'String|Float'
},
'image': {
'container': "meta[property='og:image']",
'attr': 'content',
'type': 'Image'
},
'genres': {
'container': "div[itemprop='genre'] a",
'attr': false,
'type': 'String|Array'
}
},
'seasons': {
'name': {
'container': "div.seasons-and-year-nav div>a[href*='?season=']",
'attr': false,
'type': 'String'
},
'episode_url': {
'container': "div.list.detail.eplist > .list_item a[itemprop='name'] ",
'attr': 'href',
'type': 'String'
}
},
'episodes': {
'imdb_id': {
'container': "meta[property='pageId']",
'attr' : "content",
'type' : "String"
},
'season': {
'container': "div.bp_item > .bp_content > .bp_description > .bp_heading",
'attr' : false,
'type' : "String|Split",
'action' : 'split(" ")[1]'
},
'name': {
'container': ".title_wrapper > h1[itemprop='name']",
'attr': false,
'type': 'String'
},
'directors': {
'container': "span[itemprop='director'] > a > span[itemprop='name']",
'attr': false,
'type': 'String|Array'
},
'creators': {
'container': "span[itemprop='creator'] > a > span[itemprop='name']",
'attr': false,
'type': 'String|Array'
},
'description': {
'container': ".summary_text",
'attr': false,
'type': 'String'
},
'original_title': {
'container': ".originalTitle",
'attr': false,
'type': 'String'
},
'duration': {
'container': ".title_wrapper .subtext time[itemprop='duration']",
'attr': false,
'type': 'String'
},
'rating': {
'container': "span[itemprop='ratingValue']",
'attr': false,
'type': 'String|Float'
},
'image': {
'container': "meta[property='og:image']",
'attr': 'content',
'type': 'Image'
},
'genres': {
'container': "div[itemprop='genre'] a",
'attr': false,
'type': 'String|Array'
},
},
}
These options are against imdb site updates. So you can basicly change which tag to use for getting the content. The extractor will try to extract the content from the options you passed.
To change default options you should pass your own options as a param while creating new instance of ImdbCrawler
const ImdbCrawler = require('hi-imdb-crawler');
let options = {
'movie': {
'imdb_id': {
'container': "meta[property='imdbId']",
'attr' : "content",
'type' : "String"
},
'name': {
'container': ".title_wrapper > h2[itemprop='name']",
'attr': false,
'type': 'String'
}
},
'series': {
'rating': {
'container': "span[itemprop='rating']",
'attr': false,
'type': 'String|Float'
}
}
}
let imdb_code = "tt4227538";
let imdbCrawler = new ImdbCrawler(imdb_code,options);
imdbCrawler.getEpisode(function(data) {
console.log(data);
});
Usage
to get an episode
const ImdbCrawler = require('hi-imdb-crawler');
let imdb_code = "tt4227538";
let imdbCrawler = new ImdbCrawler(imdb_code);
imdbCrawler.getEpisode(function(data) {
console.log(data);
});
to get an movie
const ImdbCrawler = require('hi-imdb-crawler');
let imdb_code = "tt0110413";
let imdbCrawler = new ImdbCrawler(imdb_code);
imdbCrawler.getMovie(function(data) {
console.log(data);
});
to get an series
You can get series with or without episodes. If you want to get with episodes basicly pass true param after callback function in getSeries
without episodes
const ImdbCrawler = require('hi-imdb-crawler');
let imdb_code = "tt4574334";
let imdbCrawler = new ImdbCrawler(imdb_code);
imdbCrawler.getSeries(function(data) {
console.log(data);
});
with episodes
const ImdbCrawler = require('hi-imdb-crawler');
let imdb_code = "tt4574334";
let imdbCrawler = new ImdbCrawler(imdb_code);
imdbCrawler.getSeries(function(data) {
console.log(data);
},true);
Running the tests
npm test
License
This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the [https://www.gnu.org/licenses/gpl-3.0.html](GNU GENERAL PUBLIC LICENSE) for details