Reputation: 3130
The page I want to parse could be get only by POST method.
This is easy for Java as I can see:
import org.jsoup.Jsoup;
Response res = Jsoup.connect("URL").method(Method.POST).execute();
Document doc = res.parse();
I could not produce the same thing using CFscript.
jsoup = createObject("java", "org.jsoup.Jsoup");
response = jsoup.connect("URL").method(Method.POST).execute();
if (response.statusCode() == 200)
{
doc = response.parse();
}
-ERR Element POST is undefined in METHOD
I tried almost everything. I was unable to use .method() and .execute() at the same time.
If I call .get() or .post() directly I can not check statusCode() back then.
Upvotes: 4
Views: 148
Reputation: 43053
Alternatively, you can invoke the post()
method directly:
response = jsoup.connect("URL").post();
Upvotes: 0
Reputation: 28873
If you look at the API, Method is another JSoup class. You need to create an instance of that class before you can access the POST constant. Also, Method is a little different than your typical java class. It is an enum (or constant). Those are essentially handled as inner classes, which require a special syntax with createObject:
methodClass = createObject("java", "org.jsoup.Connection$Method");
response = jsoup.connect("http://example.com").method(methodClass.POST).execute();
Upvotes: 5