Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Code #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/services/cfb.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default {
* @param {*} year - Year (YYYY)
* @param {number} page - Page (50 per page)
* @param {"HighSchool"|"JuniorCollege"|"PrepSchool"} group - Institution Type
* @param {"Composite"|"247"} rankingsType - Ranking Type
* @param {string} state - State of recruit
* @returns json
* @example
Expand All @@ -162,23 +163,33 @@ export default {
page = 1,
group = "HighSchool",
position = null,
state = null
state = null,
rankingsType = "Composite"
}) {
const baseUrl = `http://247sports.com/Season/${year}-Football/CompositeRecruitRankings`;
const params = {
const params = {
InstitutionGroup: group,
Page: page,
Position: position,
State: state
};

let baseUrl;
if (rankingsType === 'Composite') {
baseUrl = `http://247sports.com/Season/${year}-Football/CompositeRecruitRankings`;
} else if (rankingsType === '247') {
baseUrl = `http://247sports.com/Season/${year}-Football/recruitrankings`;
} else {
throw new Error("Invalid rankings type");
}

const res = await axios.get(baseUrl, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
},
params
});


let $ = cheerio.load(res.data);

let players = [];
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sportsdataverse",
"version": "2.0.0",
"version": "2.0.4",
"type": "module",
"description": "Node.js client which retrieves sports data from the ESPN API as well as from the NCAA website, with support for NBA, NFL, NHL, MLB, WNBA, men's and women's college basketball, and college football.",
"main": "server.js",
Expand Down