PhantomJS在弹出窗口中执行JavaScript以提取数据 [英] PhantomJS executing JavaScript in a popup for data extraction

查看:99
本文介绍了PhantomJS在弹出窗口中执行JavaScript以提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个网页,上面有一些人的照片.当您单击该人的照片时,将执行JavaScript,并弹出一个带有一些更详细信息的弹出窗口,例如说明等.

So I have a web page with some photos of people. When you click on a photo of the person the JavaScript is executed and produces a popup with some more detailed information such as a description etc.

每张照片的链接如下:

<a href="javascript:void(0)" data="10019"  class="seeMore"></a>

首先,我想从基础知识开始,即从一个人中提取描述等.因此,我想执行上面的JavaScript来编写弹出窗口,然后,当我进入弹出窗口时,可以提取弹出窗口中div's的内容.

First I want to start with the basics, of just extracting the description etc. from one single person. So I want to execute the JavaScript above to write the popup window, and when I'm on the popup window I can then extract the content of the div's on the popup.

我看过PhantomJS,但我真的不知道从哪里开始.我已经使用Cheerio从页面中获取一些简单的信息,并且我想继续通过JS执行弹出窗口,然后从中提取数据.

I've looked at PhantomJS and I really don't know where to start. I've used Cheerio to get some simple information from the page, and I want to move on to executing the popup window through JS and then extracting data from that.

任何帮助都将不胜感激,因为我通常是新手,可以进行屏幕抓取.

Any help would be appreciated as I'm a bit of a newbie to screen scraping in general.

推荐答案

您可以类似于 CasperJS

在离开主页之前,请不要忘记覆盖/清空page.onPageCreated.

Do not forget to overwrite/nullify page.onPageCreated before navigating away from the main page.

这篇关于PhantomJS在弹出窗口中执行JavaScript以提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆