I want to open a url using python script and then same python script should fill the form but not submit it For example script should open https://www.facebook.com/ and fill the name and password in the fields, but don't submit it.
Asked
Active
Viewed 1,044 times
-1
-
Please add some of your code, to show what you tried. – David Baak Sep 26 '19 at 10:17
-
I have been searching for the code. Then after looking all the net I posted my own question. can you please help? – Muhammad Ahmad Sep 26 '19 at 10:24
2 Answers
0
You can use Selenium to get it done smoothly. Here is the sample code with Google search:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.google.com")
browser.find_element_by_id("lst-ib").send_keys("book")
# browser.find_element_by_name("btnK").click()
The last line is commented intentionally if do not want to submit the search.

Dhirendra Kumar
- 333
- 2
- 5
-
getting this error upon running this selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. – Muhammad Ahmad Sep 26 '19 at 10:23
-
See https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path – Sep 26 '19 at 10:31
0
Many websites don't support Web Scraping. Actually It may cost you an illegal access case on you. But Try using requests library in python. You'll find it easy to do that stuff.
https://realpython.com/python-requests/
payload = {'inUserName': 'USERNAME/EMAIL', 'inUserPass': 'PASSWORD'}
url = 'http://www.locationary.com/home/index2.jsp'
requests.post(url, data=payload)

Satya
- 11
- 3
-
Thanks for the precautions this is for assignment purpose only. – Muhammad Ahmad Sep 26 '19 at 10:21
-
and in the question I explicitly mentioned I don't want to submit the form. just need to open the url and fill the fields – Muhammad Ahmad Sep 26 '19 at 10:22