python爬虫requests一万条数据_requests发送数据和对反爬虫的处理 ----------python的爬虫学习...

url='https://www.baidu.com/s?wd=123'

head={'User‐Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKi t/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'}

rep=requests.get(url,headers=head)

print(rep.text)

带参数的post请求

postData = { 'username':'Angela',

'password':'123456'

}

response = requests.post(url,data=postData)

添加headers中的User-Agent(标识符)....

head={'User‐Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKi t/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'}

rep=requests.get(url,headers=head)

添加其他的如:cookies、referer也是如此,在前面的urllib的反爬虫也介绍过了

cookies在requests库中的获取方法

url='https://www.baidu.com/'

req=requests.get(url)

req.cookies

url='https://www.baidu.com/'

get_cookies.get(url,headers=head)

#此时已经从百度返回一个cookies信息

#我们可以直接调用该cookies

get_cookies.get(url+'s?wd=123',headers=head)

标签:cookies,get,python,爬虫,url,537.36,发送数据,requests,head

来源: https://www.cnblogs.com/lcyzblog/p/11269341.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值