在用Java解析之前执行对网页元素的点击 [英] Perform click on web page element before parsing in Java
问题描述
我正在尝试使用dom解析器和jsoup库解析html页面. 我面临的问题是:
I'm trying to parse html page with dom parser and jsoup library. The problem that I'm facing is this:
在网站上有两个按钮,分别显示两个不同的表格. 我需要分析单击第二个按钮时显示的表. 然后设置了不同的属性值.
On web site there are two buttons which show two different tables. I need to parse table which is shown when second button is clicked. There is different attribute values set then.
当我做Jsoup.connect("example.com")
我收到响应,就像选择了第一个按钮一样,我不需要该数据.
I get response like first button is selected, and I don't need that data.
有没有一种方法可以单击第二个按钮,然后开始从网站解析和检索数据?
Is there a way to perform click on second button, and then start parsing and retrieving data from web site?
推荐答案
JSoup无法控制网页,只能解析内容.对于操纵和交互,有一些工具.我推荐 Geb ,它使用Groovy DSL和类似JQuery的语法,使其非常流畅.用它解析xml/html也很容易.
JSoup can't control the web page, only parse the content. For manipulation and interaction, there are some tools. I recommend Geb, which uses a Groovy DSL with a JQuery like syntax, making it very fluent. It's also pretty easy to parse xml/html with it.
这篇关于在用Java解析之前执行对网页元素的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!