简体   繁体   English

需要帮助从带有 simple_html_dom.php 的标签中的背景图像中提取 url

[英]need help extracting url from background-image in tag with simple_html_dom.php

am new in the scrapping world, Like to know if some one know a way to extract background-image url from a Li tag.我是报废世界的新手,想知道是否有人知道从 Li 标签中提取背景图像 url 的方法。 here I place the code from the original html page: Thank in advace....我在这里放置原始 html 页面中的代码:提前致谢....

<li class="first b-loaded" 
data-puntuacion="6,3" 
style="background-image: url(&quot;/carteles/255/primavera_en_beechwood_91776.jpeg&quot;);">

You can use Regex您可以使用正则表达式

Regex to extract url():提取 url() 的正则表达式:

url\(\S*\)

Input:输入:

    <li class="first b-loaded" data-puntuacion="6,3" style="background-image: url(&quot;/carteles/255/primavera_en_beechwood_91776.jpeg&quot;);">

Output: Output:

url(&quot;/carteles/255/primavera_en_beechwood_91776.jpeg&quot;)

在此处输入图像描述

Regex to extract the image:提取图像的正则表达式:

([/a-z0-9_-]*).(jpeg|png|gif|jpg)

在此处输入图像描述

References:参考:

https://regexr.com/ https://regexr.com/

https://www.php.net/manual/en/function.preg-match.php https://www.php.net/manual/en/function.preg-match.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM