大家好,又见面了,我是你们的朋友全栈君。
postman 导出python爬虫代码
import requests
url = "https://www.baidu.com/"
payload={
}
headers = {
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Referer': 'https://www.google.com/',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cookie': 'PSTM=1635130801; BAIDUID=3F157C96EFC2E840889BE2A9FFE0CCE6:FG=1; BD_UPN=12314753; BIDUPSID=DDA05C3E6A3EF678DE19383E02644031; __yjs_duid=1_3e85c1c0538e4d3a9a301f91573f312d1635148664115; BDUSS=l2emZtZEo0cEx4bHg1THZUeDYxZGg3Z1Z3aXhlLWdQS3JobDVFU3R-aVBkNk5oSVFBQUFBJCQAAAAAAQAAAAEAAACEksw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI~qe2GP6nthWn; BDUSS_BFESS=l2emZtZEo0cEx4bHg1THZUeDYxZGg3Z1Z3aXhlLWdQS3JobDVFU3R-aVBkNk5oSVFBQUFBJCQAAAAAAQAAAAEAAACEksw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI~qe2GP6nthWn; BAIDUID_BFESS=92B179409037CE85636EE1C6F6E952E5:FG=1; BCLID_BFESS=8891278852733992646; BDSFRCVID_BFESS=zU4OJeC627racwOHuxAA2Z9N3Rq02tvTH6ao5orta-OPsNhDcHdhEG0PjU8g0Ku--O9JogKKQgOTHRCF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; H_BDCLCKID_SF_BFESS=fnCfoCD5fIvqK4jlq4bohjPh3HO9BtQmJJufQJjJbh71ftnqLj5Aef6y0lLjJJ3qQg-q3RAaa-oMHj6O0bbFMM0SyMO30x-jLIQPVn0MW-KVKqAwy4nJyUPubPnnBpjm3H8HL4nv2JcJbM5m3x6qLTKkQN3T-PKO5bRu_CcJ-J8XMC8mD63P; B64_BOT=1; H_PS_645EC=b1a7vxMtrn6%2BjBCjyeoZcmyojoDFu1AxiLUf59y%2Fm6oV2%2BKdZf7GtHpXQhZP0vgPXFoa; COOKIE_SESSION=36487_1_8_8_6_6_1_0_8_4_0_0_36488_0_3_0_1637024417_1636983083_1637024414%7C9%23184877_41_1636983083%7C9; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BD_HOME=1; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; delPer=0; BD_CK_SAM=1; PSINO=7; H_PS_PSSID=34447_35105_35012_35051_35049_35063_34584_34517_34916_34579_34606_26350_35073_34868_35114_34994; sugstore=0; BA_HECTOR=a18g8k200la104aktk1gp62qj0r; BAIDUID=D2ECFD669E53F8E58E385FA097367B79:FG=1; BIDUPSID=D2ECFD669E53F8E522B7FE1B76FA4A4A; H_PS_PSSID=34447_35105_35012_35051_35049_35063_34584_34517_34916_34579_34606_26350_35073_34868_35114_34994; PSTM=1637025649; BDSVRTM=352; BD_HOME=1'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
下载postman工具
使用postman工具写接口测试
直接生成爬虫代码
直接复制请求头信息
拷贝所以请求头信息然后添加到postman里面
把参数复制到里面点击
点击红色的地方选择模块编程类型在选择复制
简单的爬虫代码就生成了
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/140627.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...