На самом деле я пытаюсь сделать instabot
с использованием Selenium в PyCharm и пытаюсь нажать кнопку «Мне нравится», но я не могу вызвать кнопку «Нравится» из-за ее свойства svg, если кто-нибудь знает, как нажать на кнопку «Нравится», пожалуйста, помогите мне.
Вот код:
def findhashtag(self):
self.driver.get('https://www.instagram.com/explore/tags/'+self.hashtag+'/')
like_picture = self.driver.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[1]/a/div')
like_picture.click() #this is to open picture
elememnt = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located(("xpath", '//*[local-name()="svg"][@class="_8-yf5"]')))
#self.driver.find_element_by_xpath('//button[@class="wp06b"]//*[name()="svg"]').click() #another method to click on that
#self.driver.find_element_by_xpath('//*[name()="svg"]//*[name()="viewBox" and @class="_8-yf5")').click() #another method to click on that
#self.driver.find_element_by_link_text("Like").click() #another method to click on that
follow = WebDriverWait(self.driver, 15).until(lambda d: d.find_element_by_xpath('//button[text()="Follow"]'))
follow.click() #this is to follow and its working fine
try:
like_button = WebDriverWait(self.driver, 15).until(lambda d: d.find_element_by_xpath('//button[@class="wp06b"]//*[name()="svg"]'))
like_button.click() #trying to clic[enter image description here][1]k on like button
except:
print("not liked")