javascript - Submitting form (Python) - Stack Overflow

I have a page full of links like this:<a href="javascript:Window('args')"> te

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:

  1. Filter all the links i need
  2. clicking the first link to open the popup window
  3. 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 doing this in Python, let me know)

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:

  1. Filter all the links i need
  2. clicking the first link to open the popup window
  3. 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 doing this in Python, let me know)

Share Improve this question asked Jan 4, 2011 at 18:20 AerusAerus 4,3807 gold badges46 silver badges63 bronze badges 3
  • Urgh. There's no reason to use the javascript: pseudo-protocol in HTML links these days. Leave the href empty and use onclick instead. – Daniel Roseman Commented Jan 4, 2011 at 20:04
  • 1 @Daniel I assume it is not a page the OP has written :) – Ashy Commented Jan 4, 2011 at 20:09
  • 1 @Ashy you're pletely right :) – Aerus Commented Jan 5, 2011 at 10:40
Add a ment  | 

1 Answer 1

Reset to default 5

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)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745344766a4623492.html

相关推荐

  • javascript - Submitting form (Python) - Stack Overflow

    I have a page full of links like this:<a href="javascript:Window('args')"> te

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信