I'm using Selenium
in the following manner as below:
ChromeOptions options = new ChromeOptions();
/*options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--disable-extensions");*/
WebDriverManager.chromedriver().setup();
ChromeDriver driver = new ChromeDriver(options);
driver.get("https://gearbest.net/");
WebElement ulElement = driver
.findElement(By
.cssSelector("body > div:nth-child(18) > div > div > div > div.tablets_content.clean > div > ul"));
List<WebElement> liElements = ulElement.findElements(By.tagName("li"));
//List<Article> articleList = new ArrayList<>();
//try {
/*org.jsoup.nodes.Document doc = Jsoup.connect("https://gearbest.net/products/").userAgent("Opera").get();
Elements liElements = doc
.select("#main > div.default_products_list.default_products_list1 > div.themes_plist_right > div");*/
// class of the whole element
liElements.forEach(liElement -> {
String str = ""; // this line for debugging purposes, it's redundant if we speak about production code
...
I have the problem while debugging with getting li
elements because of incorrect data.
I suppose it happens because of some missing things.
I'm ready to provide more information per your requirements, if you need.
Previously, I did it using Jsoup
as a tool:
org.jsoup.nodes.Document doc = Jsoup.connect("https://gearbest.net/products/").userAgent("Opera").get();
Elements liElements = doc
.select("#main > div.default_products_list.default_products_list1 > div.themes_plist_right > div");
But, as for now, it doesn't work because of updated version of the website, unfortunately.
I have already checked another similar question, but it doesn't look as my current use case.
If I find the way how to realize it, I'll answer on my own question.
I'm attaching additionally for you, as well, HTML for the current question.
Thank you for your attention :)
-
1Could you please add the relevant HTML? It's possible there's a better and more accurate selector than the one you are using and that might be the problem.Kate Paulk– Kate Paulk2023年08月04日 12:22:21 +00:00Commented Aug 4, 2023 at 12:22
-
@KatePaulk, yes, sure, I'll update now my question :)invzbl3– invzbl32023年08月04日 20:28:34 +00:00Commented Aug 4, 2023 at 20:28