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

curl如何遍历js跳转链接?

WBOY
Release: 2016-06-06 20:14:41
Original
1410 people have browsed it

想用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>
Copy after login
Copy after login

回复内容:

想用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>
Copy after login
Copy after login

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template