Python Forum

Full Version: Like ou Unlike Instagram
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm beginner in Python, what is the best code to validate if the instagram photo already has like or not ?
because if i run twice my script the result is unlike.

# Goto First Photo of Profile
photo_instagram = driver.find_element_by_class_name('v1Nh3').click()
time.sleep(2)
Thanks
Please, use proper tags while posting a thread. See Proper Code Tag usage
(Jun-08-2020, 06:25 PM)rmiguelantunes74 Wrote: [ -> ]Hi,

I'm beginner in Python, what is the best code to validate if the instagram photo already has like or not ?
because if i run twice my script the result is unlike.

# Goto First Photo of Profile
photo_instagram = driver.find_element_by_class_name('v1Nh3').click()
time.sleep(2)

Thanks

we need more info on how this works to help you.
Hi,

I have the code for validate

            # Validate Like or Unlike
            btn = driver.find_element_by_xpath(
                '/html/body/div[4]/div[2]/div/article/div[2]/section[1]/span[1]/button')
            aria_label = btn.find_element_by_class_name('_8-yf5 ').get_attribute('aria-label')
            if aria_label == "Like":
                # Like Photo
                like_photo = driver.find_element_by_xpath(
                    '/html/body/div[4]/div[2]/div/article/div[2]/section[1]/span[1]/button')
                like_photo.click()
                time.sleep(3)