Tips on accessing live content from a website using C#

I am facing a challenge in retrieving dynamic information automatically from a website using a C# application. Despite trying to inspect the page source code using F12 on my browser, I am unable to identify the required information.

My attempt to obtain the information using the Nuget Selenium package has also been unsuccessful. Since the information is dynamic and lacks specific IDs for selection, I'm unable to extract it from the body content or by using a select statement.

For example: I need to retrieve the name and link of each object on this page and navigate to page 2 appropriately, as the direct link leads back to page 1.

On this page, I require information on recent sales and price history for the past few days.

Despite various attempts, I have not been successful in extracting the necessary data. The code snippet below retrieves the page source but does not meet my requirements.

 private void TestReadPage()
 {
      IWebDriver driver = new ChromeDriver();
      driver.Navigate().GoToUrl("https://web.idle-mmo.com/wiki/items/mystic-sword/ZjlPA8v9NMaXNEyMe2Oa?same_window=true");

      // Attempting to get the body content, which proves futile
      var body = driver.FindElement(By.TagName("body")).Text;

      // Unable to retrieve the average sold price from the graphic
      var lastsold = driver.FindElements(By.ClassName("!border-t-0"));

        driver.Quit();
 }

Answer №1

To locate a specific element using Selenium, you can utilize the xpath method. This approach enables the script to wait until the desired element is visible on the page.

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

wait.Until(ExpectedConditions.ElementExists(By.xpath("YOUR_XPATH_HERE")));

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Executing a .NET C# function that takes an Iset<> as input, invoked from a Python 2

I am facing a challenge with a method in .NET C# that needs to be called in a specific way: public void PropagateToViews( View view, ISet<ElementId> parallelViews ) Everything seems clear except for the ISet part which I am struggling t ...

Retrieve parameters from functions and convert them into coherent statements

As I delved into the world of THREE.js, I experimented with various geometries. However, manually writing out each geometry became tedious due to the vast array of options available. For example, creating a simple cube required these lines of code: var m ...

Unable to generate dynamic HTML through AJAX request

I made an Ajax API call and received the response in JSON format. I need to create dynamic HTML to display each value in HTML elements. I tried getting the response from the API but couldn't generate the HTML. Can someone assist me with this? Also, I ...

Show only the populated fields in a user profile with ReactJS

Purpose Showcasing only completed fields. Context In my app, users fill out an application with fields like "early reg fee, early reg date, regular reg fee, regular reg date". After completing all the information and clicking "view profile", they should ...

What is the process of connecting two models in Mongoose?

In this scenario, we have two models - ProductModel and CategoryModel. The goal here is to establish a connection between creating a product (ProductModel) and assigning it to a category. The issue arises when the category field is not getting filled in t ...

Decrease initial loading time for Ionic 3

I have encountered an issue with my Ionic 3 Android application where the startup time is longer than desired, around 4-5 seconds. While this may not be excessive, some users have raised concerns about it. I am confident that there are ways to improve the ...

Is it possible to deactivate an element based on a specific string present in the URL?

<div class="custom-class1"> <div class="custom-class2" id="custom-id1">hello 1</div> <div class="custom-class3" id="custom-id2">hello 2</div> <div class="custom-class4" id="custom-id3">hello 3&l ...

Unable to toggle Bootstrap 5 tabs in a Nunjucks template - the issue persists

I have been following the bootstrap documentation for tabs which can be found at this link After referencing the documentation, I replicated the sample implementation in my code as shown below: --- title: Portfolio description: Portfolio --- {% exten ...

Tips for ensuring that the toJSON method in Sails.js waits for the find operation to complete before returning the object

When I try to run a find inside the toJSON function in the model, the object is returned before the find completes. How can I ensure that the return happens only after the find operation has completed? toJSON: function() { var obj = this.toObject(); Com ...

I am looking to add some flair to my ID "checkimg" using JavaScript

JavaScript if ((valid1 && valid2 && valid3 & valid4 && valid5 && valid6 && valid7 && valid8)==1) { // include an image in the specified ID. document.formElem.next1.disabled=false; } else { docume ...

Angular developers are struggling to find a suitable alternative for the deprecated "enter" function in the drag and drop CDK with versions 10 and above

By mistake, I was working on an older version of Angular in StackBlitz (a code-pane platform). I came across a function called enter on GitHub, but it didn't solve my issue. I was working on a grid-based drag and drop feature that allows dragging bet ...

What makes the statement 'Is it not Valid that IEnumerable<T.GetProperty(identityProperty).GetType())> Set' not logical?

Can someone help me understand why I am facing difficulty in performing the following? Let u = typeof(T).GetProperty(identityProperty).GetType(); IEnumerable<u> keySet = null; I understand this may seem straightforward to some, but I would greatly ...

Does binary search maintain its usual efficiency?

Does binary searching remain efficient and effective if an array inherits from an object? ...

Sharing Variables with $(document).ready

I need help understanding why this code is not functioning and how I can fix it. Despite my efforts to use namespaces and IIFEs, I am still unable to make it work. $(document).ready(function() { alert (hi); }); $(document).ready(function() { var hi = ...

Utilizing JavaScript to conceal div elements within a ul container

How can I hide specific div tags inside a ul tag using JavaScript? All div tags are currently getting hidden when I use the id of the ul tag. However, I need only the first div tag to be shown and the rest to be hidden. Here is the HTML code: <ul clas ...

developing a dynamic map with javascript

In the image provided, my concept is for it to initially be without a green tint. However, when the user hovers over specific areas, they would turn green and become clickable links. There are multiple areas in the image, with this being just one example. ...

How do I stop Internet Explorer from attempting to save the JSON response when using .ajaxForm with C# MVC?

When I send Json data through a C# MVC Controller, most browsers handle it correctly. However, Internet Explorer (IE9) insists on saving the returned Json as a Text file. Does anyone have suggestions on how to prevent this from happening? //MVC Controller ...

What steps are needed to convert the format to an array in JavaScript?

I have received a value in the format: [["first"],["second"],["third"]] However, I need it to be like this: {"first","second","third"} How can I achieve this using JavaScript? ...

Error: n.indexOf function is not defined - Issue with Firebase

After integrating Stripe into Firebase, I encountered an issue where a specific line of code is supposed to execute whenever a user upgrades their plan. This code should create checkout sessions in the users' collection, but it throws an error instead ...

Tips for dynamically passing a URL to a function using the onload event

I require assistance with passing a dynamic URL to a function. code onload="getImage('+ val.logo +');" onclick="loadPageMerchantInfo('+ val.merchant_id +'); The value of val.logo contains a URL such as: https://www.example.com/upload ...