POST请求

一个完整的串:

https://api.yunxuekeji.cn/yunxue_app_api/course/getCourseByTypeAndMore?orderOn=&classtype=031001004&forPeopleType=&format=&price=&pageIndex=1&pageSize=10&classTag=

一、在ApiService中

public interface ApiSerivce {
    @FormUrlEncoded
    @POST("course/getCourseByTypeAndMore")
    rx.Observable<Bean1> login1Pre(@FieldMap Map<String,String> map);
}

二、在LoginModel里

        Retrofit retrofit = new Retrofit.Builder().baseUrl(url)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
//        https://api.yunxuekeji.cn/yunxue_app_api/course/getCourseByTypeAndMore?
// orderOn=
// &classtype=031001004
// &forPeopleType=
// &format=
// &price=
// &pageIndex=1
// &pageSize=10
// &classTag=
        HashMap<String, String> objectObjectMap = new HashMap<>();
        objectObjectMap.put("orderOn","");
        objectObjectMap.put("classtype","031001004");
        objectObjectMap.put("forPeopleType","");
        objectObjectMap.put("format","");
        objectObjectMap.put("price","");
        objectObjectMap.put("pageIndex","1");
        objectObjectMap.put("pageSize","10");
        objectObjectMap.put("classTag","");
        retrofit.create(ApiSerivce.class)
                .login1Pre(objectObjectMap)
                .subscribeOn(Schedulers.io())
                .retry()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Bean1>() {
                    @Override
                    public void call(Bean1 bean1) {
                        callBacks.loginSucc(bean1);
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        String message = throwable.getMessage();
                        Log.e("-==========",message.toString());
                    }
                });

根据整体串慢慢研究其原理......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
selenium是一个用于自动化浏览器操作的工具,可以模拟浏览器的行为,进行网页的交互操作。对于post请求,selenium同样提供了相应的方法来实现。 在selenium中,我们可以使用WebDriver的`execute_script()`方法来执行JavaScript代码,从而模拟post请求。具体的步骤如下: 1. 创建一个WebDriver实例:首先,我们需要安装selenium,并导入相应的库。然后,创建一个WebDriver实例,例如ChromeDriver。 2. 打开目标网页:使用`get()`方法打开目标网页。 3. 准备post请求数据:获取需要发送的post请求的数据,可以通过找到对应的表单元素进行获取,或者手动构造数据。 4. 构造并执行post请求:使用JavaScript代码构造post请求,并通过`execute_script()`方法执行。例如,可以使用XMLHttpRequest对象来发送post请求,将准备好的数据传递进去。 5. 处理返回结果:处理post请求的返回结果,可以使用JavaScript代码提取需要的信息,或者使用WebDriver提供的方法来获取返回的网页内容。 6. 关闭WebDriver实例:完成后,记得关闭WebDriver实例。 需要注意的是,selenium的post请求是模拟浏览器的行为,并不是直接发送请求到服务器。因此,post请求在浏览器中执行时会产生网络请求,但实际的请求并没有发送出去。如果需要直接发送post请求到服务器,并获取返回的结果,可以考虑使用其他方法,如requests库等。 总而言之,selenium可以通过模拟浏览器行为实现post请求,但是对于直接发送post请求到服务器并获取结果,建议使用其他库。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值