I have a page full of links like this:
<a href="javascript:Window('args')"> text here </a>
When the link is clicked a window pops up (using Javascript). The Javascript also creates the contents of the new window. (with innerHTML
)
The content consists of a form like this:
<form method="post" action="/doaction.php">
<input type="hidden" value="hashcode">
/* code to insert data (textfields etc.) */
<input type="submit">
</form>
What i'm trying to do is:
- Filter all the links i need
- clicking the first link to open the popup window
- clicking the submit button to send the data
The first step shouldn't be to hard and i can figure that out myself.
However i have no clue how to do step 2 (but i can probably find some tutorials on how to click a link in Python) and step 3.So any help on how to start with step 3 is highly appreciated.
(Also if i really shouldn't be doi开发者_运维技巧ng this in Python, let me know)
You can use urllib2.urlopen to make a POST request to the script the form is submitting to.
import urllib, urllib2
url = '/doaction.php'
data= {'hashcode': 'blah', 'name':'blahblah', 'type':'blahblahblah'}
request = urllib2.Request(url, urllib.urlencode(data))
response = urllib2.urlopen(request)
精彩评论