Java
- 7 ответов
- 0 вопросов
2
Вклад в тег
public class Test {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("data-token=\"(.*?)\"\\W+data-ad-id=\"(.*?)\"");
String text = "<div class=\"suggesttext tleft\">\n" +
" <a href=\"#\" class=\"link clearPhoneViews\"\n" +
" data-token=\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhZElEIjoiNDU4MTI0NjQ2IiwiZXhwIjoxNTQyNDkxMzAxfQ.sJsVtqm9KyUWXlKHmaTtz43rQzWeVH0ZQSpe8NVpj7A\"\n" +
" data-ad-id=\"458124646\">\n" +
" <span>Обнулить</span>" +
"<div class=\"suggesttext tleft\">\n" +
" <a href=\"#\" class=\"link clearPhoneViews\"\n" +
" data-token=\"Vtqm9KyUWXlKHmaTtz43rQzWeVH0ZQSpe8NVpj7A\"\n" +
" data-ad-id=\"2\">\n" +
" <span>Обнулить</span>";
Matcher matcher = pattern.matcher(text);
while (matcher.find()){
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
}
}
}
String html = driver.findElement(By.tagName("html")).getAttribute("innerHTML")