-- coding: utf-8 --
import requests
from bs4 import BeautifulSoup
import random
import time
from datetime import datetime
class PublicMethod:
def init(self, def_url, headers):
self.def_url = def_url
self.headers = headers
self.def_datetime = def_datetime
def get_web_data(self):
"""
把异步加载的数据转换成json格式
:return:
"""
time.sleep(random.random() + 1)
def_web_data = requests.get(self.def_url, headers=self.headers, timeout=100)
def_soup = BeautifulSoup(def_web_data.text, 'html.parser')
# print(def_soup)
return def_soup
网友评论