简体   繁体   中英

Comment a Instagram Picture using selenium

I want to know how to comment using selenium in the comment box. I dont know which "find_element_by_x" I should use.

<textarea aria-label="Añade un comentario..." placeholder="Añade un comentario..." class="Ypffh" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>

Thanks!

inside the form there is textarea , select it by

.find_elements_by_css_selector('form  textarea')
# or
.find_elements_by_xpath('//form/textarea')

do loop to comment all post in homepage or remove s from _elements_ if you want to select first element.

to find out the element, in browser right click target and click Inspect or Inspect Element

Try this---

browser.find_element_by_xpath('/html/body/div[4]/div[2]/div/article/div[2]/section[1]/span[2]/button').click()
comment_box=browser.find_element_by_xpath('/html/body/div[4]/div[2]/div/article/div[2]/section[3]/div/form/textarea')
comment_box.send_keys('Nice!!')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM