2020-07-10
新增了代理功能,不能用的话自行修改代理即可,代码如下浅显易懂 import re import requests from requests import RequestException import time import random from bs4 import BeautifulSoup ## 获取网页的response文件 def get_response(url): try: headers = { 'Referer': 'https://blog.csdn.net', ## 伪装成从CSDN博客搜索到的文章 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36'