CamTosh / instagram-bot-dm

Instagram bot to send direct messages
GNU General Public License v3.0
326 stars 66 forks source link

Is it possible to share a post with the message? #14

Closed joaopm33 closed 2 years ago

joaopm33 commented 3 years ago

Hello, can I use this bot to send a post together with the message in DM?

I can do it in the instagram app so it would be great if its also possible here.

Anyway, thanks for the great application!

CamTosh commented 3 years ago

Hey, it's a good idea !

joaopm33 commented 3 years ago

Hello CamTosh, i maneged to do it. Here is the function to anyone who might also want it:

(def share_post(usrnamee, post_link):

    browser.get(post_link)
    time.sleep(random.uniform(4,6))

    browser.find_element_by_css_selector(".wpO6b:nth-child(3) .\\_8-yf5").click()
    time.sleep(random.uniform(4,6))

    browser.find_element_by_xpath("/html/body/div[4]/div/div/div/div[2]/div/div[1]/div/div").click()
    time.sleep(random.uniform(4,6))

    browser.find_element_by_name("queryBox").send_keys(usrnamee)
    time.sleep(random.uniform(4,6))

    browser.find_element_by_css_selector("span[aria-label='Alternar a seleção']").click()
    time.sleep(random.uniform(4,6))

    browser.find_element_by_css_selector(".cB_4K.sqdOP.y3zKF.yWX7d > .rIacr").click())

I used a portuguese css selector in this line, so you might have to change it with this button name in your language or use a different path to it.

browser.find_element_by_css_selector("span[aria-label='Alternar a seleção']").click()