Whatever your project size is, we will handle it well with all the standards fulfilled! We are here to give 100% satisfaction.
For job seekers, please visit our Career Page or send your resume to hr@actowizsolutions.com
Data has become a mighty weapon that can influence the direction of this world. This can decide the subsequent actions, which need to consider increasing sales by offering products related to customers’ tastes, using Artificial Intelligence to minimize human work, and more.
This blog will show how to scrape data from a current website; the action is generally called data scraping. For that one, we would use Tokopedia, an Indonesian E-Commerce website.
The initial step to data scraping is deciding which data we wish to get. Here, we need to find shoe (sepatu) data, and this would be organized by a review (ulasan).
Let’s observe the site. This website is formed by the markup language called HTML. And we could get the data that we want by searching the HTML of a page carefully.
Initially, let’s open the Tokopedia page at https://www.tokopedia.com.
Let’s search for the shoes on a search bar. In Indonesia, shoes are known as “sepatu”, so we will use a word “sepatu” in a search bar.
However, it’s organized by the most appropriate one, therefore, let’s change it to category by a review by changing a dropdown “Urutkan” to “Ulasan”.
Let’s observe an HTML by utilizing inspect elements or point towards a product’s card.
We can observe that a card has the class called css-y5gcsw. Then within a card, we could see some data about products.
We are interested in a name, pricing, city, and image URLs of products so let’s see an HTML element of the data.
We can observe that we can have a name using css-1b6t4dn class, pricing with the css-1ksb19c class, a city using the css-1kdc32b class, and an image having a css-1c345mg class.
After identifying the HTML of this page, let’s make a script for getting data from a page.
As Tokopedia uses JavaScript Framework to build a website, we would use the browser automation library called Selenium. We could get data from HTML using the library. Indeed, you have to install a library initially, and we want a browser, also. You could follow the Selenium installation at the link and use the virtual environment of Python for the project. For a browser, we would be utilizing Firefox for the automation procedure.
After that, it’s time to make a file called scraper.py like a place for a Scraper to reside.
Let’s make a class called Scraper, which will get the responsibility of getting data from a website. Here, we make a property called driver, which will get filled with the Selenium Webdriver. A Webdriver is the class Selenium will utilize to create a session having a browser and connecting with a browser. Therefore, if a webdriver commands a browser to open any page, the page will get opened in a browser. To make a Webdriver object connected to the Firefox browser, we could call a static function Firefox() from a Webdriver class.
After that, let’s make a function called get_data() to find data from a website. For the objective here, we require to get an URL from a website. In case, we observe that website again, we could see an URL is :
Let’s create a driver command a browser to find the URL through calling the function driver.get("URL").
After that, Just make a counter for a page, which shows products and listing to place the data.
We would get data till page 10. For every page, we would make a driver command the browser for scrolling till the end of a page as the page would not load data in case, we didn’t scroll using it. When we checked the page, we found that a page has about 6500 pixels and we would scroll every 500 pixels. For every iteration, we would wait for 0.1 seconds thus we didn’t put any load together on the server.
After the repetition for scrolling, we would get a card’s element, iterator on all elements, find the name, pricing, image, and city data, and lastly put data to a datas variable.
Then, we find all data, we could go to next page through making a driver click to next page. In case, we check HTML of a page, we could find that a page button gets css-1ix4b60-unf-pagination-item class. And we could indicate which button is needed to click through using a counter variable.
And lastly, return data like a function’s return values.
For overall codes, just check this.
Now, let’s make a file called “main.py” for checking a class functionality. Just fill a file using this code.
If we run a file, we would open a Firefox browser, and a browser would automatically search as a driver instructed within our code. After that, we can observe the results from a terminal.
We could see that we found 700 product data from a shoe-searching page!!!
Then, we would try and present data in an additional format than printing in a terminal directly.
For more information, contact Actowiz Solutions now!
You can also reach for all your mobile app scraping and web scraping services requirements.
Learn effective techniques to Scrape Google Maps POI Data safely, avoid IP blocks, and gather accurate location-based insights for business or research needs.
Learn how to build a scalable Amazon web crawler using Python in 2025. Discover techniques, tools, and best practices for effective product data extraction.
Actowiz Solutions' report unveils 2024 Black Friday grocery discounts, highlighting key pricing trends and insights to help businesses & shoppers save smarter.
This report explores women's fashion trends and pricing strategies in luxury clothing by analyzing data extracted from Gucci's website.
Leverage tyre pricing and market intelligence to gain a competitive edge, optimize strategies, and drive growth in the global tire industry.
Explore how data scraping optimizes ferry schedules and cruise prices, providing actionable insights for businesses to enhance offerings and pricing strategies.
Crumbl is growing sweeter with every bite! Check out thier recently opened locations and see how they are bringing their famous cookies closer to you with our web scraping services. Have you visited one yet
Web scraping enables businesses to access and analyze detailed product specifications from Costco, including prices, descriptions, availability, and reviews. By leveraging this data, companies can gain insights into customer preferences, monitor competitor pricing, and optimize their product offerings for better market performance.