Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Magazines;
- import java.util.List;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import com.jaunt.ResponseException;
- import com.jaunt.SearchException;
- import com.jaunt.UserAgent;
- public class scriptClass {
- public void Execute(String Username, String Password)
- throws InterruptedException, ResponseException, SearchException {
- System.setProperty("webdriver.chrome.driver", "/Applications/chromedriver");
- WebDriver driver = new ChromeDriver();
- driver.get("https://eforensicsmag.com/wp-login.php");
- WebElement username = driver.findElement(By.id("user_login"));
- WebElement password = driver.findElement(By.id("user_pass"));
- WebElement submit = driver.findElement(By.id("wp-submit"));
- UserAgent userAgent = new UserAgent();
- userAgent.visit("https://eforensicsmag.com/wp-login.php");
- userAgent.doc.fillout("Username or Email Address", Username);
- userAgent.doc.fillout("PASSWORD", Password);
- userAgent.doc.submit();
- username.sendKeys(Username);
- password.sendKeys(Password);
- submit.click();
- driver.get("https://eforensicsmag.com/magazines/");
- Thread.sleep(120000L);
- List<WebElement> tables = driver.findElements(By.className("tg-item-link"));
- System.out.println("Found " + tables.size() + " tables:");
- int count = 0;
- for (WebElement table : tables) {
- try {
- count++;
- if (count > 0) {
- String html = table.getAttribute("href");
- userAgent.visit(html);
- String temp11 = userAgent.doc.findEvery("<a rel=\"nofollow\" class=\"btn btn-primary btn-xs\"")
- .outerHTML();
- String download;
- try {
- download = temp11.substring(temp11.indexOf("href=") + 6, temp11.indexOf("';"));
- } catch (StringIndexOutOfBoundsException e) {
- download = temp11.substring(temp11.indexOf("href=") + 6, temp11.indexOf("'>"));
- }
- System.out.println(count + ": " + download);
- driver.get(download);
- }
- } catch (IndexOutOfBoundsException e) {
- System.out.println(count + ": Error");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement