我目前正在通过为网站申请来编写我的编程技巧。现在我可以通过应用程序登录网页。我现在的重点是让用户通过应用程序更改他/她的个人资料并将其保存到网站。问题是网站上什么也没发生,我没有得到任何错误代码或任何错误。
当我点击保存按钮以保存网站上的最近更改时,我收到以下标题消息(通过使用谷歌浏览器f12 - >网络):
firstname: John
lastname:Random
streetAddress:Woodstreet 12
careOfAddress:
zipCode:417 22
city:Woods
country:US
phone:111122000
languageForeignKey:4FCB3B38F96800010003004E
invoiceDeliveryMethod:email
preferredMessageMethod:sms
save_button:
utf8:✓
authenticity_token:+RadnomKey40134128Notes=
我的方法
public void setUpdatedContactInformation(String cookie, String firstName,
String lastName, String streeAdress, String coAdress,
String zipCode, String city, String country,
String alternativPhone, String language, String deliveryMethod,
String messageMethod, String token) {
try {
Response Jresponse = Jsoup
.connect(ContactInfoURL).cookie("Website-session", cookie)
.data("firstname", firstName, "lastname", lastName,
"streetAddress", streeAdress, "careOfAddress",
coAdress, "zipCode", zipCode, "city", city,
"country", country, "phone", alternativPhone,
"languageForeignKey", language,
"invoiceDeliveryMethod", deliveryMethod,
"preferredMessageMethod", messageMethod,
"authenticity_token", token)
.method(Method.POST)
.execute();
我不知道是否需要令牌,但无论如何我都用过它。我可以从之前获取令牌,因此它与记录的会话相同。函数所采用的每个输入都与表单相同,我只是将名字改为Johnnn以查看它是否有效,但John在网站上没有更改。
答案 0 :(得分:2)
修正了它!
页面上有几个按钮(顶部有一个搜索栏和一些导航按钮)。通过编辑代码并添加我关注的按钮来解决问题。新法典:
esponse Jresponse = .connect(ContactInfoURL).cookie("Website-session", cookie)
.data("firstname", firstName, "lastname", lastName,
"streetAddress", streeAdress, "careOfAddress",
coAdress, "zipCode", zipCode, "city", city,
"country", country, "phone", alternativPhone,
"languageForeignKey", language,
"invoiceDeliveryMethod", deliveryMethod,
"preferredMessageMethod", messageMethod, "save_button", button,
"authenticity_token", token)
.method(Method.POST)
.execute();
因此,基本上添加了可以通过F12捕获的按钮名称> Chrome修复了它。 :)