-1

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.

2 Answers2

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