|
发表于 2020-4-2 17:58:45
|
显示全部楼层
本楼为最佳答案
- import requests
- import bs4
- from bs4 import BeautifulSoup
- r = requests.get('https://yanyu.huijiwiki.com/wiki/伙伴成长以及加点属性排行一览')
- r.encoding = r.apparent_encoding
- html = r.text
- soup = BeautifulSoup(html, "html.parser")
- table = soup.find('table').children
- ulist = []
- for tr in table:
- if isinstance(tr, bs4.element.Tag):
- td = tr('td')
- if not td:
- continue
- ulist.append([td[0].string, td[1].string, td[2].string, td[3].string])
- print(*(" ".join(j[:-1] for j in i) for i in ulist), sep="\n")
复制代码 |
|