0
I started to develop an API for instagram. Everything is working normally, however the line code that like the publication is not finding the class.
Code to enjoy:
def curtir_fotos(self, hashtag):
driver = self.driver
self.hashtag = hashtag
driver.get('https://www.instagram.com/explore/tags/' +hashtag+ '/')
time.sleep(5)
for i in range(1, 3):
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(3)
hrefs = driver.find_elements_by_tag_name('a')
pic_hrefs = [elen.get_attribute('href') for elen in hrefs]
[href for href in pic_hrefs if hashtag in href]
print(hashtag + ' fotos: ' +str(len(pic_hrefs)))
for pic_hrefs in pic_hrefs:
driver.get(pic_hrefs)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
try:
driver.find_element_by_class_name('//button[@class="_8-yf5 "]').click()
time.sleep(10)
except Exception:
time.sleep(5)
He always falls in the except and I don’t know why. So how do I solve??
Thank you very much for the answer, but unfortunately it didn’t work... I’ve tried it in many ways and it doesn’t work. I’m really ready to give up kkk just click the button to complete and so far nothing.But I’ll keep trying.
– Luiz Henrick Abreu
but what kind of error does it present? It can make us available?
– Wellington Fonseca
No explicit error appears, but when you try to click it simply goes to next post without liking it... it’s as if it doesn’t find the element or can’t run the Butão
– Luiz Henrick Abreu
is that actually he has to click the button, the instruction I gave you click the Like icon. Maybe this is the current problem
– Wellington Fonseca
So to resolve should I click on the information where is written Button?? Sorry is that we say html is not my beach kk but I joined the area invader to do this project.
– Luiz Henrick Abreu
I believe that this case of yours is this situation. We would have to test to be sure.
– Wellington Fonseca
Would you like me to send the full code?
– Luiz Henrick Abreu