资源介绍
import requests
from bs4 import BeautifulSoup
import bs4
def getHTMLText(url):
try:
r = requests.get(url, timeout=30)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
except:
return ""
def fillUnivList(ulist, html):
soup = BeautifulSoup(html, "html.parser")
for a in soup.find('tbody').children:
if isinstance(a, bs4.element.Tag):
tds = a('td')
ulist.append([tds[0].string, tds[1].string, tds[2].string, tds[3].string])
def printUnivList(ulist, num):
print("{:^10}\t{:^6}\t{:^6}\t{:^16}".format("排名","学校名称","地区","总分"))
for i in range(num):
u=ulist[i]
print("{:^10}\t{:^6}\t{:^6}\t{:^16}".format(u[0],u[1],u[2],u[3]))
- 上一篇: 调用淘宝api,淘宝沙盒测试,获取省市区数据
- 下一篇: 淘宝商城手机排名查询大师 v1.0.zip