I can do it with Java in the following way:
Code: Select all
public static String getYoutubeURLByName(String search) throws UnsupportedEncodingException, MalformedURLException, MalformedURLException, MalformedURLException, MalformedURLException, IOException {
String google = "https://www.google.com/search?tbm=vid&hl=en-TR&source=hp&biw=&bih=&q=";
String charset = "UTF-8";
String userAgent = "Mozilla/5.0";
Elements links = Jsoup.connect(google + URLEncoder.encode(search, charset)).userAgent(userAgent).get().select(".g .r a");
String url = links.get(0).absUrl("href");
url = URLDecoder.decode(url.substring(url.indexOf('=') + 1, url.indexOf('&')), "UTF-8");
System.out.println(url);
return url;
}
But I don't know how can I retrieve the first youtube URL from google video search results in AutoHotkey.