V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Ra1nb0w
V2EX  ›  Python

请问这种 html 格式的文本怎么用 Python 处理?

  •  
  •   Ra1nb0w · Sep 7, 2021 · 2128 views
    This topic created in 1694 days ago, the information mentioned may be changed or developed.
    <tr class="infolist_hr_common" onMouseOver="javascript:this.className='infolist_hr_current'" onMouseOut="javascript:this.className='infolist_hr_common'"><th nowrap >第 1 节<br></th><td id="1-1" class="center">&nbsp;</td><td id="2-1" class="center">&nbsp;</td><td id="3-1" class="center">&lt;&lt;国际贸易实务&gt;&gt;;1<br>南 1-XXX<br>XXX<br>1-14 周<br>讲课学时<br>&lt;&lt;国际贸易实务&gt;&gt;;1<br>XXX<br>15-16 周<br>实验学时</td><td id="4-1" class="center">&nbsp;</td><td id="5-1" class="center">&lt;&lt;国际贸易学&gt;&gt;;1<br>南 1-736<br>XXX<br>1-2 周<br>讲课学时<br>&lt;&lt;国际贸易学&gt;&gt;;1<br>南 1-XXX<br>XXX<br>5-18 周<br>讲课学时</td><td id="6-1" class="center">&nbsp;</td><td id="7-1" class="center">&nbsp;</td></tr>
    </table>
    
    luckyx
        1
    luckyx  
       Sep 7, 2021
    考虑一下 beautiful soup?
    Ra1nb0w
        2
    Ra1nb0w  
    OP
       Sep 7, 2021
    @luckyx BeautifulSoup 格式化之后的会不全,不知道为什么,看了元数据是没错的。
    rationa1cuzz
        3
    rationa1cuzz  
       Sep 8, 2021
    代码不贴出来怎么? soup = BeautifulSoup(rsp, "lxml") 我的是全的
    Ra1nb0w
        4
    Ra1nb0w  
    OP
       Sep 25, 2021
    @rationa1cuzz 可以用了,谢谢,之前不知道哪里的数据处理有问题,重写了一遍好了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1194 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:15 · PVG 07:15 · LAX 16:15 · JFK 19:15
    ♥ Do have faith in what you're doing.