I am trying to send a DM on Instagram, but each new line is sent as one message.
Does type input and click not support multiple lines? If so, does anyone have any insight into alternative solutions, such as fixing this area of the puppeteer source code?
The simplified code is as follows. It may not work as it is because of the different language area. Sorry.
import pp from 'puppeteer';
import puppeteer from 'puppeteer-extra';
export const instagram = async () => {
console.log('START!!!');
const browser = await puppeteer.launch({
executablePath: pp.executablePath(),
args: [
'--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
],
headless: true,
slowMo: 100,
timeout: 30000,
});
const page = await browser.newPage();
await page.setViewport({
height: 900,
width: 1366,
});
await page.goto('https://www.instagram.com/accounts/login/');
await page.waitForSelector('input[name="username"]');
await page.type('input[name=username]', '___your_id___');
await page.type('input[name=password]', '___your_password___');
await page.click('button[type=submit]');
await page.waitForNavigation({ waitUntil: 'domcontentloaded' });
await page.goto('https://www.instagram.com/direct/__your_frend_dm_direct_url__');
await page.waitForSelector('textarea[placeholder="メッセージ..."]'); // japanese
await page.type('textarea[placeholder="メッセージ..."]', "this is\nmultiple line");
await browser.close();
};
I want to send a multi-line message in a single transmission.