将按钮插入html文件或动态地将页面内容发送到服务器

时间:2016-01-15 00:25:53

标签: javascript jquery python html

我正在尝试将html代码中的按钮放入文件中或在加载时动态生成。我是python系统编码器,所以我试图用Python解决它。

from BeautifulSoup import BeautifulSoup, SoupStrainer


html="" #Holds the mainhtml loadaed
updated_html =""  #Holds the html with the new layout
updated_html_file= open('reviw.htmlx', 'w'); # file pointer to the html file with action buttons
with open('aaaa.html', 'r+') as myfile:
    html=myfile.read();
    update_html=update_html.replace("</a>","</a><input type=\"button\" value=DMCA onclick=\"window.location.href='.html';\">DMCA</button>

    updated_html_file.write(update_html);    #Puts the DMCA button next to it
updated_html_file.close();

import socket;
import sys;

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
server_address = ('localhost', 9999);
print >>sys.stderr, 'starting up on %s port %s' % server_address;
sock.bind(server_address);
# Listen for incoming connections
sock.listen(1)

while True:
    # Wait for a connection
    print >>sys.stderr, 'waiting for a connection';
    connection, client_address = sock.accept();
    try:
        print >>sys.stderr, 'connection from', client_address;

        # Receive the data in small chunks and retransmit it;
        while True:
            data = connection.recv(16);
            print >>sys.stderr, 'received "%s"' % data;
        if data:
            print >>sys.stderr, 'sending data back to the client';
            connection.sendall(data);
        else:
            print >>sys.stderr, 'no more data from', client_address;
        break
    finally:
        # Clean up the connection
        connection.close();

现在我们有按钮,我在这里有一个服务器,它只是监听端口80并吐出它收到的内容。我几乎不知道如何做的是如何将锚链接或文本发送到服务器。我用谷歌搜索HTML和JS,但这是我第一次用HTML格式化网页,所以既不了解任何东西,也没有发现任何我可以推断的内容。我想过也许作为post方法发送到http服务器?鉴于按钮的数量,我无法弄清楚如何实现:(

无论如何我可以实现这个真正的HTML新手吗?任何提示都非常感谢。

0 个答案:

没有答案