jimmylew52
asked on
How to test the ability of a website to be logged into.
I need to test the ability of a website to be logged into. Software, script or something to log into a website and send a report by email to report if the website could be logged into or not. needs to run on Windows 2008R2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, Python does run on Linux, but you can also run it on Windows.
http://www.winservermart.com/HowTo/Install-Python-In-Windows-Server.aspx
http://www.winservermart.com/HowTo/Install-Python-In-Windows-Server.aspx
ASKER
So I see. Install python for windows but i have no idea how to get this to work. I don't see where it is installed. How do I get this script to run?
ASKER
If I'm doing this right:
I moved the python directory to c:\python
I savde the script to a file test.py
C:\python\python35\python test.py
I get:
File "test.py", line 12
print result^
SyntaxError: Missing parentheses in call to 'print'
I moved the python directory to c:\python
I savde the script to a file test.py
C:\python\python35\python test.py
I get:
File "test.py", line 12
print result^
SyntaxError: Missing parentheses in call to 'print'
ASKER
Using python 3: corrected code
#We need urllib module
import urllib.parse
import urllib.request
#These are the user and password parameters, check that field names are the same at the page form and put your real user and password values on myuser and mypassword
params = urllib.parse.urlencode({'u sername': 'UID', 'password': 'password', 'submit' : 'login'})
#This is the url of the login page, put the real url here
site = "https://mysite.mycompany.com"
#We save the result of the post in variable f
f = urllib.request.urlopen(sit e, params)
#We read the result
result = f.read()
#We print the result, so we can see if we are logged in
#print result
result = open('c:\\phython.html',w)
#Finished, so we close f
f.close()
Still getting error:
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
I think the question was answered and I will open a question in python for the answers to the error.
#We need urllib module
import urllib.parse
import urllib.request
#These are the user and password parameters, check that field names are the same at the page form and put your real user and password values on myuser and mypassword
params = urllib.parse.urlencode({'u
#This is the url of the login page, put the real url here
site = "https://mysite.mycompany.com"
#We save the result of the post in variable f
f = urllib.request.urlopen(sit
#We read the result
result = f.read()
#We print the result, so we can see if we are logged in
#print result
result = open('c:\\phython.html',w)
#Finished, so we close f
f.close()
Still getting error:
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
I think the question was answered and I will open a question in python for the answers to the error.
ASKER
Not complete answer but farther along than I was.
ASKER