Leave a comment to post in facebook with puppteer [closed]

此生再无相见时 提交于 2021-02-11 12:20:34

问题


I need help please
I try to leave a comment on posts using PUPPETEER,
I can find the post but I can not respond to the same post.
it finds me all the posts and it's not good for me,
basically what I want to do is:

  1. SCROLL DOWN
  2. Search for a post
  3. Respond to him

For example:
Someone wrote: "I am looking for a job"
Then I will respond to him "Send me a message and I will be happy to help you!"
I would be very happy for anyone who can help me.

enclose here some of my code I wrote + screenshot of the code


const navigationPromise = page.waitForNavigation();
//await page.reload()
await page.goto("https://www.facebook.com/groups/138463796814322/") //"מחפשת עבודה"
await page.waitForSelector("div[aria-hidden='true']");

await page.evaluate(_ => {
  window.scrollBy(0, window.innerHeight);
});
await page.waitForTimeout(2000);


let elements= await page.evaluate(() => {
  return  [...document.querySelectorAll("div[aria-hidden='true']")].filter(element => element.textContent.includes("looking for job"));
});

if (elements.length)
{

  for (let i=0;i<elements.length;i++)
  {

    let firebug3class = await page.$$('div._1mf._1mj');
    await page.waitForTimeout(5000);
    await firebug3class[1]?.type('looking for job? talk to me :) i help you');
  }
  //כל מי שמחפשת תלחץ קליק
  //ותגיב לה שלחי לי ווצאפ
  elements[comment]?.click();

}

SCREEN SHOOT WHAT I WANT TO DO

enter image description here

CLICK HERE

来源:https://stackoverflow.com/questions/66070005/leave-a-comment-to-post-in-facebook-with-puppteer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!