25.4.1
This commit is contained in:
parent
614227b472
commit
9d3a2c6127
14
第六周/作业三.py
Normal file
14
第六周/作业三.py
Normal file
@ -0,0 +1,14 @@
|
||||
import requests
|
||||
|
||||
uuid = requests.get('http://kdtx-test.itheima.net/api/captchaImage')
|
||||
uuid = uuid.json()['uuid']
|
||||
print(f'uuid为{uuid}')
|
||||
body = {"username": "manager",
|
||||
"password": "HM_2023_test",
|
||||
"code": "2",
|
||||
"uuid": uuid}
|
||||
request = requests.post('http://kdtx-test.itheima.net/api/login', json=body)
|
||||
data = request.json()
|
||||
cookie=request.cookies.get_dict()
|
||||
print(f'cookie为{cookie}')
|
||||
print(f'token为{data['token']}')
|
@ -1,13 +1,8 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
url='http://www.baidu.com/s'
|
||||
params={
|
||||
'wd':'Python教程'
|
||||
}
|
||||
request = requests.get(url, params=params)
|
||||
data = BeautifulSoup(request.text, 'html.parser')
|
||||
print(data)
|
||||
|
||||
# //*[@id="2"]/div/div[1]/div[1]/h3/a
|
||||
# //*[@id="3"]/div/div[1]/div[1]/h3/a
|
||||
print(request.text)
|
||||
|
20
第六周/作业四.py
Normal file
20
第六周/作业四.py
Normal file
@ -0,0 +1,20 @@
|
||||
import requests
|
||||
|
||||
import 作业三
|
||||
|
||||
body = {
|
||||
"name": "测试开发提升课01",
|
||||
"subject": "6",
|
||||
"price": 899,
|
||||
"applicablePerson": "2",
|
||||
"info": "测试开发提升课01"
|
||||
}
|
||||
headers = {
|
||||
'Authorization': 作业三.data['token']
|
||||
}
|
||||
add = requests.post('http://kdtx-test.itheima.net/api/clues/course',
|
||||
json=body,
|
||||
cookies=作业三.cookie,
|
||||
headers=headers
|
||||
)
|
||||
print(add.text)
|
Loading…
x
Reference in New Issue
Block a user