#-*-coding:utf-8-*- import requests headers = {‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36‘} #伪装 url = ‘http://www.bilibili.com/‘ html = requests.get(url, headers=headers) print html.text
伪装可以在浏览器中审查元素,network中随便选一个查看,看最底下的User-Agent就行了,顺便一提hearders是个字典。
时间: 2024-10-13 23:46:40