May-21-2020, 12:27 PM
Hi Guys,
I have put together a basic bot that opens my instagram and comments on the first photo. I have managed to make it scroll down in random intervals but am not having much success in making it find and comment of additional photos. Any ideas on how to condense this code into a single action that repeats a number of times would help. Part of my code is below.
I have put together a basic bot that opens my instagram and comments on the first photo. I have managed to make it scroll down in random intervals but am not having much success in making it find and comment of additional photos. Any ideas on how to condense this code into a single action that repeats a number of times would help. Part of my code is below.
comment = "Awesome!" driver.find_element_by_xpath("//textarea[@aria-label='Add a comment…']").click() sleep(4) driver.find_element_by_xpath("//textarea[@aria-label='Add a comment…']").send_keys(comment) sleep(4) driver.find_element_by_xpath("//button[contains(.,'Post')]").click() sleep(4) driver.execute_script("window.scrollTo(0, 2000);") sleep(4) driver.execute_script("window.scrollTo(0, 4000);") sleep(4) driver.execute_script("window.scrollTo(0, 6000);") sleep(4) print('Finished')