Hi,
I have been trying to do this for a few days now ... I'd appreciate any help or insights ...
Basically I want to enter text into a web 'textarea' automatically ... here is what I
thought I should have ...
import urllib
import urllib2
import cookielib
url2 = "someUrl"
url = "someOtherU rl"
#Create empty cookie jar.
cj = cookielib.LWPCo okieJar()
#Install cookie handler for urllib2.
opener = urllib2.build_o pener(urllib2.H TTPCookieProces sor(cj))
urllib2.install _opener(opener)
request = urllib2.Request (url, None)
f = urllib2.urlopen (request)
f.close()
# this is just to log into the site first ...
data = urllib.urlencod e({"username": "xxxxx", "password" : "somePassword"} )
request = urllib2.Request (url, data)
f = urllib2.urlopen (request)
html = f.read()
#print html
#print data
f.close()
request2 = urllib2.Request (url2, None)
t = urllib2.urlopen (request2)
t.close()
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }
#Parse the html here (html contains the page markup).
data2 = urllib.urlencod e({"message" : "rows5>blah ", "recipients[0]" : "xxxxxxx"})
#print data2
request2 = urllib2.Request (url2, data2, headers)
t = urllib2.urlopen (request2)
html2 = t.read()
print html2
t.close()
but I'm guessing that 'textarea' doesn't have a value attribute .. it looks like the text just goes between the two tags <textarea></textarea>
So how do I go about submitting predetermined text into the textarea? Do I have to parse the page and replace the whole 'textarea' section including my inputted text?
Hope you can help me,
I have been trying to do this for a few days now ... I'd appreciate any help or insights ...
Basically I want to enter text into a web 'textarea' automatically ... here is what I
thought I should have ...
import urllib
import urllib2
import cookielib
url2 = "someUrl"
url = "someOtherU rl"
#Create empty cookie jar.
cj = cookielib.LWPCo okieJar()
#Install cookie handler for urllib2.
opener = urllib2.build_o pener(urllib2.H TTPCookieProces sor(cj))
urllib2.install _opener(opener)
request = urllib2.Request (url, None)
f = urllib2.urlopen (request)
f.close()
# this is just to log into the site first ...
data = urllib.urlencod e({"username": "xxxxx", "password" : "somePassword"} )
request = urllib2.Request (url, data)
f = urllib2.urlopen (request)
html = f.read()
#print html
#print data
f.close()
request2 = urllib2.Request (url2, None)
t = urllib2.urlopen (request2)
t.close()
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }
#Parse the html here (html contains the page markup).
data2 = urllib.urlencod e({"message" : "rows5>blah ", "recipients[0]" : "xxxxxxx"})
#print data2
request2 = urllib2.Request (url2, data2, headers)
t = urllib2.urlopen (request2)
html2 = t.read()
print html2
t.close()
but I'm guessing that 'textarea' doesn't have a value attribute .. it looks like the text just goes between the two tags <textarea></textarea>
So how do I go about submitting predetermined text into the textarea? Do I have to parse the page and replace the whole 'textarea' section including my inputted text?
Hope you can help me,
Comment