在python中如何将值从一个HTML传递到另一个HTML
有两个html文件mypage.html和page.html,想要将一些值从一个html传递到另一个html,在另一个html中如何获取这些值 我正在使用的代码:在python中如何将值从一个HTML传递到另一个HTML,python,html,Python,Html,有两个html文件mypage.html和page.html,想要将一些值从一个html传递到另一个html,在另一个html中如何获取这些值 我正在使用的代码: with open('page.html', 'w') as myFile: myFile.write('<html>') myFile.write('<body>') myFile.write('<table>') myFile.write('<tr>
with open('page.html', 'w') as myFile:
myFile.write('<html>')
myFile.write('<body>')
myFile.write('<table>')
myFile.write('<tr>')
myFile.write('<td> Interface </td>')
myFile.write('<td> Global </td>')
myFile.write('</tr>')
myFile.write('<tr>')
myFile.write('<td> <a href="interface.html">Interface</a></td>')
myFile.write('<td> <a href="global.html">Global</a></td>')
myFile.write('</% print c /%>')
#myFile.write('<var>params</var>')
myFile.write('</tr>')
myFile.write('</table>')
myFile.write('</body>')
myFile.write('</html>')
#render HTML page
with open('mypage.html', 'w') as myFile:
myFile.write('<html>')
myFile.write('<body>')
myFile.write('<table>')
myFile.write('<tr>')
myFile.write('<td> Host Name </td>')
myFile.write('<td> Result </td>')
myFile.write('</tr>')
myFile.write('<tr>')
c = Cookie.SimpleCookie()
c['mycookie'] = 'cookie_value'
myFile.write('<td> <a href="page.html?params="'+final_dict.keys()[0]+ '>'+final_dict.keys()[0]+'</a></td>')
myFile.write('<td> Fail</td>')
myFile.write('</tr>')
myFile.write('</table>')
myFile.write('</body>')
myFile.write('</html>')
打开('page.html','w')作为myFile的:
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write('Interface')
myFile.write('Global')
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
#myFile.write('params')
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
#呈现HTML页面
将open('mypage.html','w')作为myFile:
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write('主机名')
myFile.write('Result')
myFile.write(“”)
myFile.write(“”)
c=Cookie.SimpleCookie()
c['mycookie']='cookie\u值'
myFile.write(“”)
myFile.write('Fail')
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
myFile.write(“”)
您可以使用php中的内置数组$\u get
获取URL参数
要从URL检索参数,您可以将此PHP代码插入网页的html源代码(您正在打开的网页包含URL中的数据):
当然,您可以使用PHP来处理这些数据。只有在启用PHP的web服务器上运行网页时,这才有效。您有一个生成html的python脚本。那很好 您正在将html保存到一个文件中,然后呢?提供文件?我猜你只生成一次文件,然后就有了静态文件。当用户实际请求url时,不会执行python代码。你应该彻底改变这种观念 您希望发生的是:
我建议你从CherryPy开始。按照文档,查找教程…这个问题是关于浏览器中的操作还是python生成脚本?要在服务器端处理“值”是什么意思?您是否可以在第1页的文本框中键入内容?您是否考虑过使用@bobsterman:也就是说,这一行(')将创建链接并转到page.html。在page.html中,希望具有'final_dict.keys()[0]的值'
<?php
echo $_GET['key'] // Will print out the data of the given key
?>