current position:Home>'request 'object has no attribute' type 'error

'request 'object has no attribute' type 'error

2022-02-02 20:24:22 CSDN Q & A

import requestsfrom urllib import requesturl = 'http://www.lagou.com/zhaopin/Python/?labelWords=label'headers = {    'User-Agent': r'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '                  r'Chrome/45.0.2454.85 Safari/537.36 115Browser/6.0.3',    'Referer': r'http://www.lagou.com/zhaopin/Python/?labelWords=label',    'Connection': 'keep-alive'}req = requests.Request(url, headers=headers)page = request.urlopen(req).read()page = page.decode('utf-8')print(page)



Refer to the answer 1:

No data was obtained , Before analyzing data , First judge whether you have climbed to the data .
req.data It's empty. .

import requestsfrom urllib import requesturl = 'http://www.lagou.com/zhaopin/Python/?labelWords=label'headers = {    'User-Agent': r'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '                  r'Chrome/45.0.2454.85 Safari/537.36 115Browser/6.0.3',    'Referer': r'http://www.lagou.com/zhaopin/Python/?labelWords=label',    'Connection': 'keep-alive'}req = requests.Request(url, headers=headers)print(req.data)



Refer to the answer 2:



Refer to the answer 3:

Request Fill in the first parameter in the .get character




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022024202822.html

Random recommended