Fill out a web form that uses javascript with python

I am trying to fill out a web form using a python program by submitting specific values. the problem is that it uses javascript. I will send an example of the value I want to fill.

fo.addVariable("email"," email@yahoo.com ") fo.addVariable("age","19") fo.addVariable("gender","M") fo.addVariable("line","hello") 

which is an example of the value on the page. what I want to do is to specify a value and change it. what I'm trying now is this:

 data = urllib.parse.urlencode({"line": "hello", "age": "50", "email": " email@yahoo.com ", "gender": "M"}).encode() resp = urlreq.urlopen("http://url.com/update", data) 

this usually works for most web forms. but for this he will not.

-1
source share
1 answer

In python 2.7, urllib does not have the urllib.parse attribute, and the .encode () function at the end is not needed.

I think you should write

 data = urllib.urlencode({"line": "hello", "age": "50", "email": " email@yahoo.com ", "gender": "M"}) 
0
source

Source: https://habr.com/ru/post/983517/


All Articles