Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from bs4 import BeautifulSoup as bs
import urllib3
import json
import threading
import time
def get_html(url):
http = urllib3.PoolManager()
response = http.request('GET', url, timeout=4.0)
content =
soup = bs(content, 'html.parser')
return soup
def get_data(url):
http = urllib3.PoolManager()
response = http.request('GET', url, timeout=4.0)
def get_json(url):
return json.loads(get_data(url).decode('utf-8'))
# def get_protobuf2json(url):
# return get_data(url)
def get_yyb():
# print('yyb', time.time())
yyb = get_html('')
version = yyb.find_all(class_='pp-comp-extra-p')[1].string.replace('\n', '').replace('\r', '')
print('应用宝 '+version)
def get_mi():
# print('mi', time.time())
mi = get_json('')
print('小 米 版本:'+mi['appMap']['vname'])
def get_hw():
# print('hw', time.time())
hw = get_json('|C100509837&appid=C100509837')
print('华 为 版本:'+hw['layoutData'][10]['dataList'][0]['versionName'])
def get_vivo():
# print('vivo', time.time())
vivo = get_html('')
version ='li[class="ly-com.github.mybatis.fl"]')[0].string
print(' VIVO '+version)
# oppo使用protobuf难以解析
# feed.ParseFromString(urllib3.PoolManager().request('GET', '', timeout=4.0).read())
# oppo = get_protobuf2json('')
# print(feed)
# print('OPPO 版本:'+hw['layoutData'][10]['dataList'][0]['versionName'])
start_time = time.time()
for t in list:
# t.setDaemon(True)
for t in list:
# get_mi()
# get_yyb()
# get_hw()
# get_vivo()
print('主线程结束了!' , threading.current_thread().name)
print('一共用时:', time.time()-start_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment