Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在html页面中解析jquery以获取python中的加载url_Jquery_Python_Html - Fatal编程技术网

在html页面中解析jquery以获取python中的加载url

在html页面中解析jquery以获取python中的加载url,jquery,python,html,Jquery,Python,Html,我在html页面中有以下java脚本代码片段: <script type="text/javascript"> jQuery(document).ready(function(){ jQuery("#data1").load("/link-to-data-1 table"); }) </script> jQuery(文档).ready(函数(){ jQuery(“#data1”).load(“/link-to-data-1表”); })

我在html页面中有以下java脚本代码片段:

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery("#data1").load("/link-to-data-1 table");
    })
</script>

jQuery(文档).ready(函数(){
jQuery(“#data1”).load(“/link-to-data-1表”);
})

请建议使用HTML解析器或任何其他解析器从上述脚本获取url:/link-to-data-1的一些好方法。通过使用HTML解析器,我们试图解析handle_data中的数据,我们得到的数据是string
jQuery(document).ready(function(){jQuery(#data1”).load(“/link-to-data-1 table”);)
我们希望以结构化方式从上述数据中提取url链接/link-to-data-1。

使用正则表达式,您将能够匹配类似于
加载\(\“(.*)\”\)
的内容,这将获取您需要的内容,我在这里举了一个示例。Rubular工具由Ruby正则表达式提供支持,但这些基本功能可以在所有引擎中移植


我的例子中的匹配项是非贪婪的,所以下面的例子也是正确的,如果url总是在
load()
函数中,为什么不编写一个正则表达式来提取
load()
之间的字符串呢?谢谢你的时间和回答,jQuery(document).ready(function(){jQuery(#data1”).load(“/link-to-data-1 table”);})不客气,如果对您有帮助,请记住用左边的“勾号”图标接受我的答案。感谢比克斯的时间和回答,从下面我只需要获取data1的url jQuery(document).ready(function(){jQuery(#data1”).load(“/link-to-data-1 table”);jQuery(#data2”).load(“/link-to-data-2 table”);jQuery(“#data3”).load(“/link-to-data-3 table”);jQuery(#data4”).load(“/link-to-data-4 table”);})正则表达式引擎将为您提供许多“匹配”(参见我的Rubular示例)-第一个匹配将是
/link-to-data-1
,这通常称为
$1
\1
,或通过您的语言提供。(对于Java,您可以阅读以获得更多关于如何开始的感觉)。将正则表达式保持为“贪婪”更容易,这样它可以找到所有加载的链接,然后您可以将它们作为一个数组包含在代码中,只需取第一个,当然您也可以扩展正则表达式来实现这一点: