Home >Backend Development >PHP Tutorial >curl如何遍历js跳转链接?

curl如何遍历js跳转链接?

WBOY
WBOYOriginal
2016-06-06 20:14:411412browse

想用CURL遍历抓取网站,但一个网站的链接都是用js跳转的,请问有没有办法抓取?如果是ajax载入部分页面内容呢?
它的网站链接类似这样:

<code>
<ul id="menu">
<li><span class="link" url="path/to">title</span></li>
</ul>
<div id="content">
</div>

<script>
$('.link').click(function(){
    var url=$(this).attr('url');
    $.get(url,function(data){
        $('#content').html(data);
    })
});
</script></code>

回复内容:

想用CURL遍历抓取网站,但一个网站的链接都是用js跳转的,请问有没有办法抓取?如果是ajax载入部分页面内容呢?
它的网站链接类似这样:

<code>
<ul id="menu">
<li><span class="link" url="path/to">title</span></li>
</ul>
<div id="content">
</div>

<script>
$('.link').click(function(){
    var url=$(this).attr('url');
    $.get(url,function(data){
        $('#content').html(data);
    })
});
</script></code>

header头302跳转 直接加CURLOPT_FOLLOWLOCATION参数 JavaScript跳转preg匹配跳转URL

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn