ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### 发送Get请求 ``` response = requests.get(url) ``` #### 发送Post请求 ``` params = {"username":"test", "password":"123456"} url = ""; response = requests.post(url, params=params) print(response.content.decode("utf8")) ``` #### 带header ``` # 字典 headers = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" } res = requests.get("http://www.baidu.com", headers=headers) print(res.content.decode("utf8")) ``` #### 带参数 ``` params = {"wd":"python"} res = requests.get("http://www.baidu.com/s", params=params) print(res.content.decode("utf8")) ``` #### 带cookies ``` cookie = { "BIDUPSID":"D81407B3929874E033B26BFA559A40AA", "PSTM":"1553073292", "BD_UPN":"12314753", "BAIDUID":"1808BB63DB4C15F95AE3141424C6CDB1:FG=1", "BDORZ":"B490B5EBF6F3CD402E515D22BCDA1598", "H_PS_PSSID":"26525_1469_21088_28720_28557_28697_28584_28603_28626_28606", "delPer":"0", "BD_CK_SAM":"1", "PSINO":"2", "__guid":"136081015.3917885664703660000.1553507929455.5535", "H_PS_645EC":"ac91oiP38ZUUGt5wKhMqG4qYocA4Yd0SMxmoTj12lQiPomhA%2FYwCLnp%2F6gs", "BD_HOME":"0", "monitor_count":"3", } response = requests.get("http://www.baidu.com", cookies=cookie) print(response.content.decode("utf8")) ```