Please note: While a similar question has been asked on JSoup:How to Parse a Specific Link, I have a more specific variation of this inquiry. Kindly read on for further details.
In order to extract data from a particular site link, I am looking to utilize the Document
select()
method for optimal efficiency. What CSS Selector Query should be employed for this purpose?
Below is one example of my attempt that failed to compile:
import org.jsoup.*;
import org.jsoup.nodes.*;
import org.jsoup.select.*;
import org.jsoup.Connection.*;
import java.io.*;
import java.util.*;
public class WebInteraction {
public Document accLogin(Account ac, String url) {
Document doc;
doc = Jsoup.connect(url).data("name", ac.username, "code", ac.pass).method(Method.POST).execute().parse();
Elements verify = doc.select(a[href*="/logout"]);
}
}
Error Message :
$ javac WebInteraction.java
WebInteraction.java:17: error: cannot find symbol
Elements verify = doc.select(a[href*="/logout"]);
^
symbol: variable a
location: class WebInteraction
WebInteraction.java:17: error: cannot find symbol
Elements verify = doc.select(a[href*="/logout"]);
^
symbol: variable href
location: class WebInteraction
2 errors