miklamer 0 Newbie Poster

Hello everyone!

I have a problem so i want to ask how to do that.
I'm goint to write program for form fill.

step by step:
1- login
2- fill form 'hostname' (then submit)
3- fill form ip/log/pass/description (then submit)
4- read web. if there is a problem refresh site if there is no errors submit.

Easy, but not for me ;) He is going to add value to database by asp web form. there is a problem couse for last submit he sens request flew times with error to write it and he send error for example to add ip address and i have to refresh browser. then he put ip in database but he crack in password or sth. So i want to write a script. i have a problem. couse he have to works in loop. and i have a problem to read web after reload. Please help me (thx for sugestion!)

import urllib2,urllib
import httplib
import re
import sys
import time
import datetime
import Cookie
from mechanize import Browser
from urllib import urlencode
from urllib2 import Request
import mechanize
#import xlrd


url = "https://localhost/patDefineSWE.jsp"
login = "miklamer"
haslo = "miklamer123"
host = "somedomain.com"
klient = ""
pt_login = "ASB\PATROL"
pt_haslo = "patrol_abs_patrol_somedomain123"


print "===> Uruchomienie"
br = Browser()   # uruchomienie przegladarki


# ewentualny debugging
#br.set_debug_redirects(True)
#br.set_debug_responses(True)
#br.set_debug_http(True)

br.open("https://localhost/login/logged_on/info.jsp?from=main")

 
##################
# LOGOWANIE

br.select_form(name="login") # wypelnienie formularza
br["j_username"] = login
br["j_password"] = haslo
response_in = br.submit() # wyslanie formularza

 
##################
#PatDefine
br.open(url)

##################
# FORMULARZ1
br.select_form(name="ftcARS") # wypelnienie formularza
br["fqdn"] = host
br["cst"] = klient
response_in = br.submit() # wyslanie formularza
print response_in
##################
# FORMULARZ2

br.select_form(name="askINFO") # wypelnienie formularza

#br["ip"] = ""
br["pat_id"] = pt_login
br["pat_pw"] = pt_haslo
br["type"] = ["win"]


request2 = br.submit()

odpowiedz = request2.read()


if odpowiedz.find("NOT") == -1:
    print "NIE OK"
    print request2.read()
    print br.title()
    print request2.geturl()
    print request2.info()  # headers
    print request2.read()  # body
    print br.form
    print br.response()
else:
    print "OK"
    print request2.read()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.