1、get请求
import requests def lx(url,headers): response = requests.get(url=url ,headers=headers) if response.status_code == 200: print(response.text) return None if __name__ == '__main__': url = 'https://www.9k9k.com/shouyou/rmjh_98915.html' headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36'} lx(url=url,headers=headers)
2、post请求
impot request def login(email, password, _xsrf, captcha): data = { '_xsrf': _xsrf, 'password': password, 'email': email, 'captcha': captcha } login_url = 'https://www.zhihu.com/login/email' response = session.post(login_url, data=data, headers=headers) if response.status_code == 200: print(response.text) return None