I wonder if you can search YouTube using HtmlUnit . I started writing code, here it is:
import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput; public class HtmlUnitExampleTestBase { private static final String YOUTUBE = "http://www.youtube.com"; public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException { WebClient webClient = new WebClient(); webClient.setThrowExceptionOnScriptError(false);
Now I do not know how to enter text in the search field and click the "Search" button.
I saw tutorials about HtmlUnit, but I have a problem because they use a method called: getElementByName , but the YouTube search button does not have a name, but only an identifier. Can someone help me?
EDIT: I edited the code above the code and now I get YouTube links from the first page. But before that, I need to sort by download date, and then grab the links. Can someone help me sort?
java youtube htmlunit
Ivan Bishevac
source share