pip install requests pip install pyquery
import requests
from pyquery import PyQuery as pq
def myCsdn():
print('aaa')
html = pq('https://blog.csdn.net/weixin_39800144')
list = html.find(".grade-box dl").items()
for l in list:
hanzi = l.find("dt").text()
if(hanzi == '访问:'):
print(l.find("dt").text() + l.find("dd").attr.title)
elif(hanzi == '等级:'):
dengji = l.find("dd").find("a").attr.title
dengji2 = dengji.split(',')
print(l.find("dt").text() + dengji2[0])
else:
print(l.find("dt").text() + l.find("dd").text())
myCsdn()
aaa
等级:5级
访问:200124
积分:4654
排名:8939