Skip to content

Instantly share code, notes, and snippets.

@AlexGodard
Last active November 28, 2024 22:44
Show Gist options
  • Save AlexGodard/0514a35b769e942acec796efa0a8c7a4 to your computer and use it in GitHub Desktop.
Save AlexGodard/0514a35b769e942acec796efa0a8c7a4 to your computer and use it in GitHub Desktop.
Fotmob
import crypto from "node:crypto";
// Make sure to have no new lines at the start and end
const secretLyrics = `[Spoken Intro: Alan Hansen & Trevor Brooking]
I think it's bad news for the English game
We're not creative enough, and we're not positive enough
[Refrain: Ian Broudie & Jimmy Hill]
It's coming home, it's coming home, it's coming
Football's coming home (We'll go on getting bad results)
It's coming home, it's coming home, it's coming
Football's coming home
It's coming home, it's coming home, it's coming
Football's coming home
It's coming home, it's coming home, it's coming
Football's coming home
[Verse 1: Frank Skinner]
Everyone seems to know the score, they've seen it all before
They just know, they're so sure
That England's gonna throw it away, gonna blow it away
But I know they can play, 'cause I remember
[Chorus: All]
Three lions on a shirt
Jules Rimet still gleaming
Thirty years of hurt
Never stopped me dreaming
[Verse 2: David Baddiel]
So many jokes, so many sneers
But all those "Oh, so near"s wear you down through the years
But I still see that tackle by Moore and when Lineker scored
Bobby belting the ball, and Nobby dancing
[Chorus: All]
Three lions on a shirt
Jules Rimet still gleaming
Thirty years of hurt
Never stopped me dreaming
[Bridge]
England have done it, in the last minute of extra time!
What a save, Gordon Banks!
Good old England, England that couldn't play football!
England have got it in the bag!
I know that was then, but it could be again
[Refrain: Ian Broudie]
It's coming home, it's coming
Football's coming home
It's coming home, it's coming home, it's coming
Football's coming home
(England have done it!)
It's coming home, it's coming home, it's coming
Football's coming home
It's coming home, it's coming home, it's coming
Football's coming home
[Chorus: All]
(It's coming home) Three lions on a shirt
(It's coming home, it's coming) Jules Rimet still gleaming
(Football's coming home
It's coming home) Thirty years of hurt
(It's coming home, it's coming) Never stopped me dreaming
(Football's coming home
It's coming home) Three lions on a shirt
(It's coming home, it's coming) Jules Rimet still gleaming
(Football's coming home
It's coming home) Thirty years of hurt
(It's coming home, it's coming) Never stopped me dreaming
(Football's coming home
It's coming home) Three lions on a shirt
(It's coming home, it's coming) Jules Rimet still gleaming
(Football's coming home
It's coming home) Thirty years of hurt
(It's coming home, it's coming) Never stopped me dreaming
(Football's coming home)`;
const createXFmReqHeader = (path: string) => {
const body = {
url: path,
code: new Date().getTime(),
};
const signature = crypto
.createHash("md5")
.update(`${JSON.stringify(body)}${secretLyrics}`)
.digest("hex")
.toUpperCase();
return btoa(
JSON.stringify({
body: body,
signature: signature,
}),
);
};
const path = "<your_path>"; // example: /api/leagues?id=130&ccode3=CAN
const response = await fetch(`https://www.fotmob.com${path}`, {
headers: {
"Content-Type": "application/json",
"x-mas": createXFmReqHeader(path),
},
});
const body = await response.json();
console.log(body)
@briankariuki
Copy link

Does not work anymore

@AlexGodard
Copy link
Author

Does not work anymore

Make sure you have the empty lines in the lyrics. Github omits them from the selection when selecting text via mouse in the original post.

It's easier to copy/paste from the raw gist: https://gist.github.com/AlexGodard/0514a35b769e942acec796efa0a8c7a4/raw/6b480cfaa55652d477ba937a9ba8e21cdb39ab03/fotmob-request.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment