What is the difference between scraping Nordstrom's mobile site and desktop site?

Scraping Nordstrom's mobile site versus its desktop site involves different considerations, primarily because of the differences in the structure, content, and layout of the two versions of the site. Here are some key differences to consider when scraping these two versions:

1. User-Agent:

When you send a request to a website, the User-Agent header tells the server what type of device is requesting the content. Desktop sites and mobile sites often respond with different HTML content based on this header.

  • Desktop User-Agent Example: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3
  • Mobile User-Agent Example: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Mobile Safari/537.36

When scraping, you can switch the User-Agent to target either the mobile or desktop site:

import requests

headers = {
    'User-Agent': 'Your User-Agent Here'

response = requests.get('https://shop.nordstrom.com/', headers=headers)

2. HTML Structure:

The HTML structure might be different between the mobile and desktop versions. Mobile sites are often more streamlined and might have fewer features or a simplified navigation system.

3. JavaScript Content:

Some content on modern websites is loaded dynamically using JavaScript. The way JavaScript is handled can differ between mobile and desktop sites. Some mobile sites may have less JavaScript to reduce load times.

4. CSS and Responsive Design:

Mobile sites use different CSS styles, which might hide or alter the appearance of elements compared to the desktop version. Responsive design techniques can also change the page structure dynamically based on the screen size.

5. URL Structure:

Sometimes mobile sites are hosted on a subdomain (like m.nordstrom.com) or a subdirectory (like shop.nordstrom.com/mobile). The URL structure can affect how you build your scraping logic.

6. Performance Optimization:

Mobile sites might be more optimized for performance, meaning they could have fewer images, lower resolution, or more compressed content.

Scraping Considerations:

When scraping a website like Nordstrom's, you should:

  • Respect the website’s terms of service: Check Nordstrom's robots.txt file and terms of service to understand the rules around scraping their content.
  • Be mindful of legality: Scraping can be a legal grey area; make sure you understand the implications.
  • Avoid excessive requests: Too many rapid requests can harm the site's performance and may lead to your IP being blocked.
  • Handle JavaScript: If the site loads content dynamically, you might need tools like Selenium, Puppeteer, or browser-based scraping to execute the JavaScript and access the content.

Example of Scraping with Selenium in Python:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

options = webdriver.ChromeOptions()
options.add_argument('--user-agent=Your Mobile User-Agent Here')

driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)

# Perform your scraping actions here


Example of Scraping with Puppeteer in JavaScript:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.setUserAgent('Your Mobile User-Agent Here');
  await page.goto('https://shop.nordstrom.com/');

  // Perform your scraping actions here

  await browser.close();

Note: Always remember that scraping can be subject to legal and ethical considerations. Websites often have specific rules about scraping, and it is important to comply with their terms of service and applicable laws.

Related Questions

Get Started Now

WebScraping.AI provides rotating proxies, Chromium rendering and built-in HTML parser for web scraping