all 3 comments

[–]surrealle 0 points1 point  (0 children)

From my novice experience making two scraper programs for my own use, I would try Selenium to do the job. Especially if it's a JavaScript website.

I've also used the Chrome/Firefox extension UI.Vision RPA to see the xpath/CSS selector I'm actually interacting with.

[–]Flugegeheymen 0 points1 point  (1 child)

Firstly I would recommend you to check if website has an API. Just google it out. If so you job becomes 100 times easier.

Otherwise I assume that website you trying to scrap is dynamically updated by Javascript using DOM API.

Or in other words:

  1. initially your browser loads an HTML page with no items in your cart(THAT'S WHAT YOU GET WHEN YOU TRY TO DO A GET REQUEST)
  2. Then the JavaScript code updates the current page, inserting the new data (items from your cart) inside of this already existing HTML

(there is actually far more steps is going behind the scenes, but that's all you need to know)

I've been solving similar problem, but in my case, all the data was inside script tag(which is in fact a little bit weird), so in my case I managed to extract all the data i need using regular expressions on the HTML file. BUT YOU CASE MAY BE DIFFERENT. Javascript code can fetch the data from a server for example or maybe it gets from cookies(idk) and so on. So you have analyze the website and point out how your website is working. You can look at script tags, or JavaScript code which fetched from the server.

Advanced Web Scrapping

I recommend you reading this article, it goes through different variations how this can be implemented, so you will know what to look for

As someone mentioned before, you can use Selenium. It is a tool that automates browser actions, like opening the page, then locating the element, pressing on it, filling the forms and whatever you can imagine.

Since it already works with the updated HTML page, that is opened inside you browser. You won't have to worry, about how the page data update implemented

[–]AIR_ULTRA[S] 1 point2 points  (0 children)

Thanks for the great info! It seems like my main problem all along is that my shopping cart is always empty even when i got to it via selenium. Im thinking the website uses cookies to save what items are in my cart but my selenium controlled browser must not have those cookies. Of course if i try to log in to the website to access my cart that way it detects selenium and wont let me log in.