Skip to content

Instantly share code, notes, and snippets.

@vikiboss
Created October 9, 2022 05:48
Show Gist options
  • Save vikiboss/a7955f8d300bd4201836b947915ee01f to your computer and use it in GitHub Desktop.
Save vikiboss/a7955f8d300bd4201836b947915ee01f to your computer and use it in GitHub Desktop.
Offer Show Scripts
// usage: node --no-warnings offer.mjs 米哈游 前端
const args = process.argv.slice(2);
const js_code = ''; // get by wx.login method in WeChat
const api = 'https://www.ioffershow.com/V4';
const silentLogin = async (js_code) => {
const res = await fetch(`${api}/silent_login`, {
method: 'POST',
body: `js_code=${js_code}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'gzip,compress,br,deflate',
Host: 'www.ioffershow.com',
'User-Agent':
'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.29(0x18001d2c) NetType/4G Language/zh_CN',
Referer: 'https://servicewechat.com/wx67fbba6cd94591e4/56/page-frame.html'
}
});
const data = await res.json();
console.log(data);
return data.data?.data?.token;
};
const fetchSalary = async (token) => {
const form = new FormData();
form.append('content', args.join('+'));
form.append('ordertype', 2);
form.append('search_priority', 1);
form.append('part_school', '');
form.append('xueli', '');
form.append('year', '');
const res = await fetch(`${api}/search_salary`, {
method: 'POST',
body: form,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'gzip,compress,br,deflate',
Host: 'www.ioffershow.com',
'User-Agent':
'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.29(0x18001d2c) NetType/4G Language/zh_CN',
Referer:
'https://servicewechat.com/wx67fbba6cd94591e4/56/page-frame.html',
token
}
});
const { data = [] } = await res.json();
for (const {
company,
position,
salary,
salarytype,
xueli,
time,
score,
city
} of data) {
console.log(
`(${score})${company}(${city})-${position}\t-${salary}(${salarytype}, ${xueli}) ${time}`
);
}
};
(async () => {
// token expired in 10 minutes
const token = await silentLogin(js_code);
if (!token) {
console.log('token 获取失败');
process.exit();
} else {
await fetchSalary(token);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment