Encountering insurmountable obstacles in accessing AliExpress

I'm looking to extract specific information from aliexpress using scrapy and selenium. However, I've encountered an issue where the HTML code appears differently when inspecting with Chrome compared to viewing the source.

It seems that the content is loaded asynchronously, which may be why I can't find the desired element on the page.

I attempted to use selenium to load the page first and then retrieve the necessary content, but was unsuccessful. My goal is to scroll down to access reviews section and obtain its content.

Could this be an advanced anti-bot measure implemented by AliExpress, or am I approaching the problem incorrectly?

This is my current code:

import scrapy
from selenium import webdriver
import logging
import time

logging.getLogger('scrapy').setLevel(logging.WARNING)


class MySpider(scrapy.Spider):
    name = 'myspider'
    
    start_urls = ['https://pl.aliexpress.com/item/32998115046.html']

    def __init__(self):
        self.driver = webdriver.Chrome()

    def parse(self, response):
        self.driver.get(response.url)

        scroll_retries = 20
        data = ''
        while scroll_retries > 0:
            try:
                data = self.driver.find_element_by_class_name('feedback-list-wrap')
                scroll_retries = 0
            except:
                self.scroll_down(500)
                scroll_retries -= 1

        print("----------")
        print(data)
        print("----------")
        self.driver.close()

    def scroll_down(self, pixels):
        self.driver.execute_script("window.scrollTo(0, {});".format(pixels))
        time.sleep(2)

Answer №1

By monitoring requests in the "network" tab of the inspect tool on your browser, you will discover that the comments originate from this specific web page: here. As an alternative, you have the option to scrape data from that page instead.

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

To ascertain whether the mouse is still lingering over the menu

I have a condensed menu construction that unfortunately cannot be changed in HTML, only CSS and JS modifications are possible! $('span').on("hover", handleHover('span')); function handleHover(e) { $(e).on({ mouse ...

Coloring a table in vue.js based on performance rankings

I'm facing an issue with sorting my data performance in vue js. Here is the script I have created so far: <template> <div> <div class="row"> <h2> Campaign Performance </h2> <table class=&q ...

Utilizing Jquery to transform characters into visual representations

Do you think it is wise to utilize a jQuery function that replaces each character in a text with custom character images? For instance, when using the function, you need to specify which element you would like the characters replaced in, and jQuery will d ...

Is it possible to set a single Tailwind breakpoint that will automatically apply to all CSS styles below it?

Responsive design in Tailwind is achieved by using the following code snippet: <div className="sm: flex sm: flex-row sm: items-center"></div> It can be cumbersome to constantly include the sm: breakpoint for each CSS rule. I want ...

Is it Feasible to Use Accumulators in XPath with Python?

Is it feasible to perform an accumulation in XPath? Take a look at my code: driver = webdriver.Chrome() driver.get('http://www.imdb.com/user/ur33778891/watchlist?ref_=wt_nv_wl_all_0') wait = (WebDriverWait, 10) x = 1 while True: try: ...

Choosing the right framework for implementing push notifications can be a critical decision. Should

I am currently working on a Java application that requires the server to send push notifications to the client every one second. To achieve this, I am using HTML5 server-sent events for one-way communication from the server to the client. However, my conce ...

inventory of concentrated outcomes

Currently, I am working on creating a model that is expected to have output dimensions of (A,B). To achieve this, I am in the process of forming a list of dense layers consisting of A elements, each producing B outputs. The ultimate goal is for my final ou ...

Implement a grid layout for columns within the profile section

Each user on my website has a profile tab that displays their submitted posts. To showcase these posts, I utilize the following code: <?php while ($ultimatemember->shortcodes->loop->have_posts()) { $ultimatemember->shortcodes->loop-> ...

Retrieving table names while querying database in Python Flask

Recently, I made the switch from PHP to Flask after three years. I successfully connected to my local server and database, and managed to query data from it and display it on screen. However, when attempting to work on a small REST API project, I ran int ...

Show the cost on the HTML page according to the chosen currency option

I am currently dealing with two primary currencies in my business. The product page is created using HTML. There are 4 products on a single page, and I wish to display two prices for each product based on the selected currency (USD or EUR) without having t ...

Double-click required to toggle button

Here is the code snippet for controlling an LED using a web page. The script, linked to Python, effectively controls the LED. However, there is an issue where the button toggles to the right side (ON position) only after a double click. Upon first click ...

loop not functioning properly with file type input

Having trouble uploading an image and copying it into a folder named images within a loop. Can you assist with solving this issue? Here's my code: $sql="SELECT * FROM product"; $q=$conn->query($sql); while($r=$q->fetch(PDO::FETCH_ASSOC)) { $cod ...

Automatically populate the next dropdown menu depending on the answer provided in the previous field

Can you help guide me in the right direction with 2 questions I have? If the answer to the first question is 1, then I would like the following answer to automatically be populated as Yes. Please assist me! <div class="field"> <!-- Number of Em ...

Viewing YouTube videos on an iPhone can be done through a web view

I am having some trouble playing videos in this specific format. http://www.youtube.com/embed/lNOMZoF9VlM?rel=0 Here is my HTML string. NSString *html = [NSString stringWithFormat:@"<html><head>\ <body s ...

I keep receiving an error in Angular JS but I'm unsure of the reason

I've been working on AngularJS and created a basic module and controller. I'm attempting to show the data of an element inside the controller on the HTML view page, but all I see is {{student.name}} and I'm receiving an error message that sa ...

Encountering Keyerror while trying to parse JSON in Python

Recently, I developed a program for extracting data from an API that returns information in JSON format. However, when attempting to parse the data, I encountered a key error. Traceback (most recent call last): File "test.py", line 20, in <module> ...

Valid ways to ensure that a CSS image expands outside the boundaries of the containing div

I have inserted an image using the following CSS code: .imgtemp { float:right; top:0px; left:0px; overflow:visible; width:100%; } Although I have added the div tag to display it on the page, ...

implement adding a division element to the DOM using the append

I am facing an issue with this particular code. The intended functionality is to create multiple divs in a loop, but it seems to be dysfunctional at the moment. Upon clicking, only one div appears and subsequent clicks don't trigger any response. < ...

Trouble arises when adding a .js script to the webpage

I'm feeling quite puzzled by this small piece of code, as it appears to be the simplest thing you'll come across today. Despite that, I can't help but seek guidance because I've been staring at it for what feels like an eternity and can ...

What is the best way to align an element at the bottom in order to allow it to grow vertically

I have a unique structure on one of my pages that I want to use for a tooltip style behavior. When the "container" element is clicked, the "child" element, which is initially hidden, should appear above the container. However, since the child's height ...