I'm having trouble replying to a tweet link using selenium and python. I tried find_element_by: id, xpath, class_name and more and not having any luck. I just cantt find the element. Is Twitter making this impossible?
Asked
Active
Viewed 1,523 times
0
-
1Is there any particular reason for using Selenium? Twitter has an API that allows automated interactions (subject to API limits), for which there are a number of Python libraries. – asongtoruin Feb 01 '18 at 10:25
-
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example.](https://stackoverflow.com/help/mcve) – undetected Selenium Feb 01 '18 at 10:31
1 Answers
3
I got it to work:
driver.get(link)
number = link.split("/")
number = number[len(number) - 1]
driver.find_element_by_id("tweet-box-reply-to-" + number).click()
driver.find_element_by_id("tweet-box-reply-to-" + number).click()
driver.find_element_by_id("tweet-box-reply-to-" + number).send_keys(comment)
driver.find_element_by_id("tweet-box-reply-to-" + number).send_keys(Keys.CONTROL + "\n")

CarlThePerson
- 493
- 4
- 8
-
What is the content in variable link? Would you give some examples? Thanks. – Charlie 木匠 Dec 11 '21 at 05:00