-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
596 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM phusion/passenger-nodejs:latest | ||
RUN apt-get update \ | ||
# Install latest chrome dev package, which installs the necessary libs to | ||
# make the bundled version of Chromium that Puppeteer installs work. | ||
&& apt-get install -y wget --no-install-recommends \ | ||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-unstable --no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = true | ||
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini /tini | ||
RUN chmod +x /tini | ||
ENTRYPOINT ["/tini", "--"] | ||
|
||
ADD ./app /app | ||
RUN npm install | ||
|
||
EXPOSE 3000 | ||
|
||
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,100 @@ | ||
# bet365-live-soccer-scraper | ||
|
||
Bet365 Live Soccer Score Scraper | ||
|
||
## Config | ||
|
||
Propably you should change config file `/app/config.js` . | ||
|
||
```javascript | ||
domain: "mobile.288365.com", | ||
intervalTimes: { | ||
list: 1, // 1 sec. | ||
reload: 1200, // 60*20 = 20 min. | ||
proxy: 60 // 1 min. | ||
}, | ||
proxyListAddr: "" // proxy list addr. http://blabla/proxy.json | ||
``` | ||
|
||
The `proxyListAddr` address should be return like this because we need host, port, type, username and password for using the proxy. You can leave the address blank. | ||
|
||
```javascript | ||
[ | ||
{ | ||
host: "172.17.0.1", | ||
port: "6000", | ||
type: "http", | ||
username: "userr", | ||
password: "pwd" | ||
}, | ||
{ | ||
host: "172.17.0.2", | ||
port: "6002", | ||
type: "http", | ||
username: "userr", | ||
password: "pwd" | ||
} | ||
]; | ||
``` | ||
|
||
The `intervalTimes`has 3 variables. | ||
`list` process list interval time. | ||
`reload` browser reload interval time. if you set to 0 this feature won't work. | ||
`proxy` proxy list fetch interval time | ||
|
||
```javascript | ||
intervalTimes: { | ||
list: 1, // 1 sec. | ||
reload: 1200, // 60\*20 = 20 min. | ||
proxy: 60 // 1 min. | ||
} | ||
``` | ||
|
||
# How to Use? | ||
|
||
## via Docker | ||
|
||
Pls look at the `reload.sh` file. | ||
|
||
## via npm | ||
|
||
`cd app;npm install;npm start` | ||
|
||
# URL's | ||
|
||
`/connect` open a browser and connect to bet365 | ||
|
||
`/close` close browser | ||
|
||
`/reload` close browser and connect to bet365 | ||
|
||
`/screenshot` it returns browser screenshot | ||
|
||
`/showip` it opens `https://whatismyipaddress.com/` and returns the screenshot | ||
|
||
`/params` it shows puppeter params. | ||
|
||
`/proxyList` it returns proxy list | ||
|
||
`/pickProxy/:id` You can choice proxy by id. | ||
|
||
`/clearProxyParam` it removes proxy from params.You should reload browser for apply the changes. | ||
|
||
`/html` it returns page html data | ||
|
||
`/result` it returns results. | ||
|
||
`/`it returns results. Status `212` means match's suspended. | ||
|
||
## Notes | ||
|
||
This software for education only. I don't take any responsibility. | ||
|
||
You can get betting odds from bet365 if you change the parser codes in `bet365mobile.js`. It will be your responsibility. | ||
|
||
## screen shots | ||
|
||
 | ||
 | ||
 | ||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import puppeteer from "puppeteer"; | ||
import { JSDOM } from "jsdom"; | ||
import { getProxy } from "./proxy"; | ||
import config from "./config"; | ||
let page; | ||
export const device = require("puppeteer/DeviceDescriptors")["iPhone X"]; | ||
export const cookieDomain = config.domain; | ||
export const mainDomain = `https://${cookieDomain}/`; | ||
export const liveDomainPath = `https://${cookieDomain}/#/IP/`; | ||
|
||
export const connect = async ({ params }) => { | ||
try { | ||
/** create a browser instance, then a page instance with it */ | ||
const browser = await puppeteer.launch(params); | ||
|
||
page = await browser.newPage(); | ||
|
||
await page.emulate(device); | ||
|
||
let proxy = getProxy(); | ||
if (proxy !== false) { | ||
await page.authenticate({ | ||
username: proxy.username, | ||
password: proxy.password | ||
}); | ||
} | ||
|
||
var cookie = [ | ||
// cookie exported by google chrome plugin editthiscookie | ||
{ | ||
domain: "." + cookieDomain, | ||
expirationDate: parseInt(Date.now() / 1000) + 10 * 36 * 24 * 3600, | ||
name: "aps03", | ||
path: "/", | ||
value: "lng=1&tzi=1&oty=2&ct=197&cg=0&cst=0&hd=N&cf=N" | ||
}, | ||
{ | ||
domain: "." + cookieDomain, | ||
expirationDate: parseInt(Date.now() / 1000) + 10 * 36 * 24 * 3600, | ||
name: "session", | ||
path: "/", | ||
value: "processform=0" | ||
} | ||
]; | ||
await page.setCookie(...cookie); | ||
await page.goto(mainDomain); | ||
|
||
await page.goto(liveDomainPath); | ||
await page.waitForSelector( | ||
".ipo-ClassificationMenuBase>div.ipo-Classification.sport_1", | ||
{ | ||
timeout: 10000 | ||
} | ||
); | ||
// Bet365 Logo flip :D | ||
await new Promise(resolve => { | ||
setTimeout(resolve, 5000); | ||
}); | ||
// await page.type(String.fromCharCode(13)); | ||
await page.click( | ||
".ipo-ClassificationMenuBase>div.ipo-Classification.sport_1", | ||
{ | ||
timeout: 10000 | ||
} | ||
); | ||
return { page, browser }; | ||
} catch (e) { | ||
console.log(mainDomain, liveDomainPath, cookieDomain); | ||
console.log(e); | ||
browser.close(); | ||
return e.toString(); | ||
} | ||
}; | ||
|
||
export const getList = async () => { | ||
// return await page.evaluate(() => { | ||
try { | ||
let e = await page.content(); | ||
let dom = new JSDOM(e); | ||
|
||
let document = dom.window.document; | ||
const matches = []; | ||
const matchesELM = document.querySelectorAll( | ||
"div.ipo-Fixture_TimedFixture" | ||
); | ||
|
||
matchesELM.forEach(matchELM => { | ||
try { | ||
// console.log(matchELM); | ||
let match = {}; | ||
let scores = matchELM.querySelectorAll("span.ipo-Fixture_PointField"); | ||
if (scores.length == 2) { | ||
// console.log(scores[0].innerHTML); | ||
// console.log(scores[1].innerHTML); | ||
match["scoreA"] = scores[0].innerHTML; | ||
match["scoreB"] = scores[1].innerHTML; | ||
} | ||
let teams = matchELM.querySelectorAll( | ||
"div.ipo-Fixture_CompetitorName > div" | ||
); | ||
if (teams.length == 2) { | ||
// console.log(teams[0].innerHTML); | ||
// console.log(teams[1].innerHTML); | ||
match["home"] = teams[0].innerHTML; | ||
match["away"] = teams[1].innerHTML; | ||
} | ||
match["time"] = matchELM.querySelector( | ||
".ipo-Fixture_GameInfo.ipo-Fixture_Time" | ||
).innerHTML; | ||
match["status"] = | ||
matchELM.querySelectorAll(".ipo-ParticipantDummy_Suspended").length > | ||
0 | ||
? "212" | ||
: "211"; | ||
matches.push(match); | ||
} catch (exception) { | ||
console.log(exception); | ||
} | ||
}); | ||
return matches; | ||
} catch (e) { | ||
console.log(e); | ||
return e.toString(); | ||
} | ||
// }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export default { | ||
params: { | ||
executablePath: "/opt/google/chrome-unstable/google-chrome", | ||
headless: true, | ||
devtools: false, | ||
ignoreHTTPSErrors: true, | ||
args: [ | ||
"--no-sandbox", | ||
"--disable-setuid-sandbox", | ||
"--disable-dev-shm-usage", | ||
"--disable-gpu", | ||
"--disable-extensions", | ||
"--disable-dev-tools", | ||
"--disable-infobars", | ||
"--ignore-certificate-errors" | ||
// debug logging | ||
// "--enable-logging", | ||
// "--v=1" | ||
// '--proxy-server=127.0.0.1:9876', | ||
] | ||
}, | ||
domain: "mobile.288365.com", | ||
intervalTimes: { | ||
list: 1, | ||
reload: 1200, | ||
proxy: 60 | ||
}, | ||
proxyListAddr: "" | ||
}; |
Oops, something went wrong.