use of me.ruslanys.vkmusic.exception.VkException in project selenium_java by sergueik.
the class ScraperVkClient method fetchUserId.
@Override
@SneakyThrows
public Long fetchUserId() {
Connection.Response response = Jsoup.connect(PATH_BASE).userAgent(USER_AGENT).cookies(cookies).method(Connection.Method.GET).execute();
Matcher matcher = Pattern.compile("id: (\\d+)").matcher(response.body());
if (!matcher.find() || "0".equals(matcher.group(1).trim())) {
throw new VkException("Не удалось получить ID пользователя.");
}
Long id = Long.valueOf(matcher.group(1));
log.info("User ID: {}", id);
return id;
}
Aggregations