前提
前些时,要考专业英语了,看见室友一边对着百度翻译,一边复习单词,心生一想法,页面明显是动态加载出来的,我能不能抓到它返回的东西,然后提取出来,这样可以弄成以个客户端,可以试一试。
观察
打开百度翻译的页面,调用浏览器的开发者模式,输入一个“你好”,然后刷新,观察请求在哪里,其实挺简单的,一下子就可以看到,请求,如下图
![请求观察](https://img-blog.csdn.net/20171228185835511?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2F5bmVRVA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
看到这里问题就十分的简单了,直接去看它的请求头,url,等等信息。就不贴图了,我直接把东西复制过来。
Request URL:http:
Request Method:POST
Status Code:200 OK
Remote Address:106.39.162.57:80
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http:
Content-Encoding:gzip
Content-Type:application/json
Date:Thu, 28 Dec 2017 10:46:41 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
Content-Length:135
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOU