我写了一个网络爬虫脚本 代码是::
<?php
include_once('simple_html_dom.php');
$target_url = "http://jvlaunchcalendar.com/calendar/";
$html = new simple_html_dom();
$html->load_file($target_url);
$ret = $html->find('div[class=fc-event-inner');
//to print the caleder events similar code //works for other sites like flipcat.com
foreach($ret as $post)
{
echo $post.'<br />';
}
echo $html;// to print the calender of jvlaunchcalendar.com site
?>
此脚本适用于其他网站。 但我想要 http://jvlaunchcalendar.com/calendar/ 的所有日历事件页面但此脚本不显示任何事件给出空日历。 请帮我获取日历的事件。
问候。
最佳答案
当您尝试 $html->load_file($target_url);
时,您会得到没有任何事件的空页面,因为事件是使用 ajax 加载的。
获取事件的简单解决方案:跟踪 ajax url 调用并加载它,而不是页面。 (我检查了,它返回json
数据,一切正常)。
但这并不好。其他方式 - 在 WordPress 中使用 native 日历功能进行操作。
关于php - 网络爬虫脚本不适用于日历事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13874277/