获取两个对象之间的链接

2024-06-11 02:13:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我这里有数据

<div class="main-details mt10">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-7" data-purpose="introduction">
                                    <div class="slp-jwplayer-communicator" data-fade-in="1"
                         data-playerhtml='            <iframe id="hh"
                    src="https://localhost/embed/video/E0cZc345xCVTXwT/?params%5Bvars%5D%5Bplaylist%5D%5B0%5D%5Bimage%5D=https%3A%2F%2Flocalhost.images.com%2Fckxit%2F750x422%2F469292_6c3e_5.jpg&params%5BtrackVideoPlay%5D=true"
                    width="100%"
                    height="100%"
                    frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen
                    style="background: black;">
            </iframe>
        '>
                        <div class="promo-asset-content stretchy-wrapper ud-courseimpressiontracker"
                             data-id="erew343423"
                             data-tracking-type="proms"
                            >
                            <div>
                                <img class="cth" src="https://lcoalhost/data/469292_6c3e_5.jpg"/>
                            </div>
                        </div>
                    </div>
                            </div>
            <div class="col-lg-4 col-md-5">
                <div class="row fxdc lf-wrap-md">
                    <div class="fxw-md -md db-xs">
                        <div class="right-top col-md-12 col-sm-6">

<div class="take-btn">
            <div class="price fxac">

                    </div>

            <a class="ct "
       data-requireLogin="true"
       data-les="button-enroll-b"
       data-padding="0"
       data-passDtCode="true"
       data-purpose="take-this"
       href="https://localhost/code=kKp5D213TWOo">
        Take </a>

我想找到jwplayer并得到src之间的所有东西

jwplayer-communicator" data-fade-in="1"
data-playerhtml=' <iframe id="4222780"
src="https://localhost/embed/video/E0cZc345xCVTXwT/?params%5Bvars%5D%5Bplaylist%5D%5B0%5D%5Bimage%5D=https%3A%2F%2Flocalhost.images.com%2Fckxit%2F750x422%2F469292_6c3e_5.jpg&params%5BtrackVideoPlay%5D=true"

结果:

https://localhost/embed/video/E0cZc345xCVTXwT/?params%5Bvars%5D%5Bplaylist%5D%5B0%5D%5Bimage%5D=https%3A%2F%2Flocalhost.images.com%2Fckxit%2F750x422%2F469292_6c3e_5.jpg&params%5BtrackVideoPlay%5D=true

但是,下面的代码将返回jwplayer中的所有内容以及结果之外的文本。你知道吗

data = re.search(r'jwplayer.*src=\"(.*?)\"', html, re.MULTILINE | re.DOTALL).group(1)

如果正好在jwplayer之后,我怎么能把src=“和”之间的所有内容都放进去呢?你知道吗

编辑

好的,我知道了。html解析器更适合处理这类问题(html)。但是我只是好奇如何在regex中执行这样的操作,有人能帮我吗?这些信息是有用的谁知道我可能会遇到这样的问题,在一个文本文件在未来。此外,即使我使用html解析器,我也需要传递一些正则表达式。你知道吗


Tags: httpsdivsrcidtruelocalhostdatahtml