mercredi 12 septembre 2018

How to enter values into a web page and click on a checkbox using python

I'm trying to enter values into a webpage and click on accept using the following code.

import urllib.request
import urllib.parse
import re

url = "https://www.mahadiscom.in/"



value={'consumer_no':170687006****,
      'terms': 'Yes',
       'vc_general vc_btn3 vc_btn3-size-md vc_btn3-shape-rounded vc_btn3- 
style-modern vc_btn3-color-juicy-pink.submit':True
    }

data = urllib.parse.urlencode(value)
data = data.encode('ascii')

req = urllib.request.Request(url,data)

with urllib.request.urlopen(req) as response:
   the_page = response.read()

string = re.search('^You have selected to pay', str(the_page))

I have attached an image of the form where i'm trying to fill the data.

Form I'm trying to fill

I'm wondering if this is even the way to do it!!




Aucun commentaire:

Enregistrer un commentaire