Home > other >  How to insert number into website and receive output it generates
How to insert number into website and receive output it generates

Time:12-19

I'm trying to get a list of catalan numbers. Python calculator breaks with huge numbers. How could I make a for loop and put the n'th number into this website enter image description here

and then you just need to right-click on the element in this new window and then copy->copy selector as shown below. Then you have all you want! enter image description here


5-Interacting with the element Here, we have the path of the element by coping from chrome. here we need to find this element in python and then interact with it! For this purpose:

path = "Enter the CSS selector that you copied"
elem = driver.find_element('css selector', path)

elem.clear() # to clear the text box
elem.send_keys("Your desired number")

And you did it! Enjoy automatically inputting a number by Python! Be aware to type Exactly 'css selector' with a lower letter to not get any errors!:-)

6-clicking on Calculate button This is the same as the previous section! You just need to copy the selector of this button by Righ-click and:

path = "Enter the CSS selector that you copied"
elem = driver.find_element('css selector', path)
elem.click()
sleep(0.5) # waiting a little time to ensure that the calculation has been completed

7- Extracting result from output textbox This is also very similar to the last step! You need to copy the CSS selector of the output textbox by Chrome and:

path = "Enter the CSS selector that you copied"
elem = driver.find_element('css selector', path)
result = elem.txt

Congratulation! You have done it! the last step is to put this code in a 'for' loop and then sit and drink your tea while python does this repetitive work for you!

  • Related