python报错:AttributeError: ‘set‘ object has no attribute ‘items‘

python报错:AttributeError: ‘set‘ object has no attribute ‘items‘_第1张图片

报错的原因是定义的header有问题 

header的正确定义格式如下:

header={“key”:“value”}

报错时的格式

headers={

    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0'}

缺失了引号

修改后

}headers={

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0'

}

注意!注意格式!!!

你可能感兴趣的:(python爬虫基础知识,爬虫)