-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
|
||
import json | ||
import requests | ||
from requests.models import encode_multipart_formdata | ||
|
||
url = 'https://fanyi.baidu.com/sug' | ||
|
||
headers = { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36' | ||
} | ||
|
||
data = { | ||
'kw': 'eye' | ||
} | ||
|
||
# url 请求地址 | ||
# data 请求参数 | ||
# kwargs 字典 | ||
response = requests.post(url=url, data=data, headers=headers) | ||
|
||
content = response.text | ||
print(content) | ||
|
||
obj = json.loads(content) | ||
print(obj) | ||
|
||
# 总结: | ||
# (1)post请求不需要编解码 | ||
# (2)post请求的参数是data | ||
# (3)不需要请求对象的定制 |