ruby 提交web表单数据的问题,web高手指教下

Python026

ruby 提交web表单数据的问题,web高手指教下,第1张

require 'net/http'

url = URI.parse('你要提交的地址')

Net::HTTP.start(url.host, url.port) do |http|

req = Net::HTTP::Post.new(url.path)

req.set_form_data({ '参数1' =>'值1', '参数2' =>'值2' })

http.request(req).body

&表示同时掌握, | 表示可选但至少一个。

前端: HTML &JS &CSS

后端:J2EE | .NET | PHP | Ruby

数据库:MySQL | Oracle | SQLServer

以上你掌握之后,方可成型。另外,学后端的任何一门都会涉及到数据库编程、网络编程。

一步一步来吧,没有一下子就成才的。

另外 <form action="提交的URL地址">

比如 <form action="/user/login">你在后端有写过映射到 /user/login 的地址,以后你懂的。

本文实例讲述了python通过get,post方式发送http请求和接收http响应的方法。分享给大家供大家参考。具体如下:

测试用CGI,名字为test.py,放在apache的cgi-bin目录下:

#!/usr/bin/python

import cgi

def main():

print "Content-type: text/html\n"

form = cgi.FieldStorage()

if form.has_key("ServiceCode") and form["ServiceCode"].value != "":

print "<h1>Hello",form["ServiceCode"].value,"</h1>"

else:

print "<h1>Error! Please enter first name.</h1>"

main()

python发送post和get请求

get请求:

使用get方式时,请求数据直接放在url中