我打算编写一个代码,将帖子请求发送到网站并获得结果。 从这个图中你可以看到post请求有3个参数:(在表单数据部分)d,n,q
我尝试过以下代码,但总是收到错误。
import requests
url = 'http://www.kloth.net/services/nslookup.php'
payload = {'d':'google.com','n':'localhost', 'd':'SOA'}
session = requests.Session()
session.post(url',headers=headers,data=payload)
你可以帮我解决这个问题!
答案 0 :(得分:0)
import requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
'Host:www.kloth.net',
'Origin':'http://www.kloth.net',
'Proxy-Connection':'keep-alive',
'Referer':'http://www.kloth.net/services/nslookup.php}
payload = {'d': 'google.com',
'n': 'localhost',
'q': 'SOA}
session = requests.Session()
return = session.post('http://www.kloth.net/services/nslookup.php', data = payload, headers = headers)
print str(return.content)
您没有指定标题,