V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2021-09-07 21:56:08 +08:00 · 1301 次点击
    这是一个创建于 955 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <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  
       2021-09-07 22:14:23 +08:00
    考虑一下 beautiful soup?
    Ra1nb0w
        2
    Ra1nb0w  
    OP
       2021-09-07 22:44:11 +08:00
    @luckyx BeautifulSoup 格式化之后的会不全,不知道为什么,看了元数据是没错的。
    rationa1cuzz
        3
    rationa1cuzz  
       2021-09-08 09:18:46 +08:00
    代码不贴出来怎么? soup = BeautifulSoup(rsp, "lxml") 我的是全的
    Ra1nb0w
        4
    Ra1nb0w  
    OP
       2021-09-25 02:44:03 +08:00
    @rationa1cuzz 可以用了,谢谢,之前不知道哪里的数据处理有问题,重写了一遍好了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1204 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:03 · PVG 02:03 · LAX 11:03 · JFK 14:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.