Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

html - Perform click on Web page element before parsing in Java

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 the table which is shown when the second button is clicked. There are different attribute values set after clicking the second button.

When I do 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Jsoup is just a parser, i.e. it can't handle events such as clicking on buttons. Have a look at browser automation tools (e.g. Selenium) to perform this kind of job.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...