爬取内容时,我们的ip可能会被网站封掉。这个时候就需要用代理来爬。下面是使用代理的简单例子

1
2
3
4
5
6
7
8
9
10
import requests

proxies = {
"https": "112.47.3.53:3128",
# "http": "112.47.3.53:3128",
}

response = requests.get("https://www.baidu.com", proxies=proxies)
response.encoding = 'utf-8'
print(response.text)