先上效果图:
经常抓包时出来的数据是这样的:
每次模拟的话都需要手动构建这些数据的键值对
这个操作很繁琐而且很容易出错所以我准备做一个这种小工具
分析文本发现可以直接搜索替换
java源代码:
package com.mycompany.myapp2;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class MainActivity extends Activity
{
String a="";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onHeadersButtonClick(View view)
{
TextView textView3 = (TextView) findViewById(R.id.mainEditText1);
textView3.getText();
a=a+textView3.getText();
String b= a.replace("\n","‘,\n‘");
b=b.replace(": ","‘:‘");
b="{\n‘"+b+"‘\n}";
TextView textView2 = (TextView) findViewById(R.id.mainEditText2);
textView2.setText(b);
a="";
}
public void onCookiesButtonClick(View view)
{
TextView textView3 = (TextView) findViewById(R.id.mainEditText1);
//textView3.getText();
a=a+textView3.getText();
String b= a.replace(" ","");
b=b.replace(";","‘,\n‘");
//b=b.replace(";\n","‘,\n‘");
b=b.replace("=","‘:‘");
b="{\n‘"+b+"‘\n}";
TextView textView2 = (TextView) findViewById(R.id.mainEditText2);
textView2.setText(b);
a="";
}
}
布局的xml代码:
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="top|center">
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CCOOKIES OR HEADERS:"
android:textSize="20sp"/>
android:layout_width="match_parent"
android:ems="10"
android:layout_height="match_parent"
android:hint="请输入原数据:"
android:gravity="top"
android:id="@+id/mainEditText1"/>
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COOKIES TO DICTS"
android:onClick="onCookiesButtonClick"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="headers TO DICTS"
android:onClick="onHeadersButtonClick"/>
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DICTS:"
android:textSize="20sp"/>
android:layout_width="match_parent"
android:ems="10"
android:layout_height="match_parent"
android:hint="转换结果在这里:"
android:gravity="top"
android:id="@+id/mainEditText2"/>
效果图: