title | tags | parameters | reference | |||||
---|---|---|---|---|---|---|---|---|
いつでも相談できるオンラインメンターが見つかるサイトMENTAで各メンターさんからの最新のメッセージを取得します |
|
|
Last active
January 3, 2021 00:42
-
-
Save freddiefujiwara/ff305353279f776d5f917359832a4298 to your computer and use it in GitHub Desktop.
dogbot-menta-latest-message.js
This file contains hidden or 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
const { | |
I | |
} = inject(); | |
module.exports = { | |
async run() { | |
// 1.MENTAのトップページのログインボタンをクリック | |
I.amOnPage('https://menta.work/'); | |
I.click('ログイン'); | |
// 2. ログインフォームからログイン (環境変数から MENTA_EMAIL, MENTA_PASSWORD を取得しています) | |
I.fillField('email', process.env.MENTA_EMAIL); | |
I.fillField('password', process.env.MENTA_PASSWORD); | |
I.click(locate('button.login_btn').withText('ログイン')); | |
// 3. メッセージリンクをクリック | |
I.click('メッセージ'); | |
// 4. メッセージ一覧を取得 | |
let entry = await I.grabNumberOfVisibleElements('div.memberMsgBox > a.msg_box'); | |
if (0 === entry) return; // なかったら諦める | |
// 5. 各メッセージページに遷移して最新のメッセージ情報を取得 | |
const messages = await I.grabAttributeFromAll('div.memberMsgBox > a.msg_box', 'href'); | |
for await (let message of messages) { | |
I.amOnPage(message); | |
const menterName = await I.grabTextFrom('div.form_head > a'); | |
const latestName = await I.grabTextFrom('div.name'); | |
const latestTime = await I.grabTextFrom('div.date'); | |
I.say(`OUTPUT: MENTER: ${menterName}/ LASTSENDOR: ${latestName} at ${latestTime}`); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment