当前位置: 首页 > 工具软件 > Httpx > 使用案例 >

python爬虫 httpx的用法

邵星河
2023-12-01

安装命令:        pip install httpx

请求方式

GET

import httpx
​
headers = {'user-agent': 'my-app/1.0.0'}
params = {'key1': 'value1', 'key2': 'value2'}
url = 'https://httpbin.org/get'
r = httpx.get(url, headers=headers, params=params)

POST

r = httpx.post('https://httpbin.org/post', data={'key': 'value'}) 

PUT

r = httpx.put('https://httpbin.org/put', data={'key': 'value'})

DELETE

 r = httpx.delete('https://httpbin.org/delete') 

 类似资料: