我尝试将表单数据发送到以下网址:https://peepoo.gq 我尝试添加标头,以及普通浏览器发送的chrome网络日志中的几乎所有内容,但我总是遇到错误405。我的代码:
import requests
url = 'https://peepoo.gq/'
payload = {'content' : 'bruh'}
headers = {
'accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
'content-type' : 'application/x-www-form-urlencoded',
'accept-encoding' : 'gzip, deflate, br',
'accept-language' : 'en-US,en;q=0.9',
'cache-control' : 'max-age=0',
'content-length' : '12',
'dnt' : '1'
}
params = {'guestbook_name' : 'main'}
r = requests.post(url, data=payload, headers=headers, params=params, allow_redirects=False)
print(r)
答案 0 :(得分:1)
以下代码对我有用:
import requests
url = 'https://peepoo.gq/sign'
payload = {'content' : 'pickle rick'}
headers = {
'content-type' : 'application/x-www-form-urlencoded',
}
params = {'guestbook_name' : 'main'}
r = requests.post(url, data=payload, headers=headers, params=params, allow_redirects=True)
基本上,您需要允许重定向,并且您的url
需要指向https://peepoo.gq/sign
答案 1 :(得分:0)
您正在使用不接受的POST方法(Klaus D.已经说过),并且使用public class VideoCard {
private String type;
private String connection;
private int power;
private String extPower;
private int memory;
public VideoCard(){
this.setType("integrated");
this.setConnection("N/A");
this.setPower(100);
this.setExtPower("N/A");
this.setMemory(1);
}
public VideoCard(String type, String connection, int power, String extPower, int memory){
this.setType(type);
this.setConnection(connection);
this.setPower(power);
this.setExtPower(extPower);
this.setMemory(memory);
}
public void setType(String type){
this.type = type;
}
public void setConnection(String connection){
this.connection = connection;
}
public void setPower(int power){
if(power>= 1 && power<=300){
this.power = power;
} if(power<1) {
this.power = 75;
} if(power>300){
this.power = 200;
}
}
public void setExtPower(String extPower){
this.extPower = extPower;
}
public void setMemory(int memory){
if(memory>=1 && memory<=12){
this.memory = memory;
} if(memory<1){
this.memory = 1;
} if(memory>12){
this.memory = 12;
}
}
public String getType(){
setType(this.type);
return type;
}
public String getConnection(){
setConnection(this.connection);
return connection;
}
public int getPower(){
setPower(this.power);
return power;
}
public String getExtPower(){
setExtPower(this.extPower);
return extPower;
}
public int getMemory(){
setMemory(this.memory);
return memory;
}
public String getInfo(){
String info = String.format("Type:\t\t%s\n " + "Connection:\t%s\n " + "Power:\t\t%sW \n " + "Ext Power:\t%s\n " + "Memory:\t%dGB \n ",
getType(), getConnection(), getPower(), getExtPower(), getMemory());
return info;
}
参数,该方法还将信息传递给data
方法。
除此之外,您还要传递两次以下键值对:POST
一次进入'guestbook_name' : 'main'
,一次进入url
。
答案 2 :(得分:0)