E-commerce scraper needs shortening
If you find yourself, doing something over and over again, loops are often the answer.

Your code rewritten with a loop:

import re

import requests
from bs4 import BeautifulSoup

urls = {
    "Charms": "https://us.pandora.net/en/charms/?sz=30&amp;start={}&amp;format=page-element",
    "Bracelets": "https://us.pandora.net/en/bracelets/?sz=30&amp;start={}&amp;format=page-element",
    "Rings": "https://us.pandora.net/en/rings/?sz=30&amp;start={}&amp;format=page-element",
    "Necklaces": "https://us.pandora.net/en/necklaces/?sz=30&amp;start={}&amp;format=page-element",
    "Earrings": "https://us.pandora.net/en/earrings/?sz=30&amp;start={}&amp;format=page-element"
}

for category, url in urls.items():
    soup = BeautifulSoup(requests.get(url.format(0)).text, 'lxml')
    total_items = ''.join(re.findall(r'\d', soup.select_one('span.products-count').text))
    print("Total {}: {}".format(category, total_items))


So what has changed? The URLs went into a dictionary where the category's name is the key. A simple list would also work here in your case. Now we can iterate over that dictionary. With for category, url in urls.items(): you get the key, i.e. the name of the category and the URL at the same time.

The loop body now does what you had written out by hand, namely getting the page, parse the content with BeautifulSoup and than again with a regex.

Since the URL came bundled with the category, we can no print all the results nicely without writing the same code over and over again.

You can also go a step further and make this into a function:

import re

import requests
from bs4 import BeautifulSoup


def get_total_items(url):
    """Parse the product count from the given pandora URL"""
    soup = BeautifulSoup(requests.get(url).text, 'lxml')
    return ''.join(re.findall(r'\d', soup.select_one('span.products-count').text))


if __name__ == "__main__":
    urls = {
        "Charms": "https://us.pandora.net/en/charms/?sz=30&amp;start={}&amp;format=page-element",
        "Bracelets": "https://us.pandora.net/en/bracelets/?sz=30&amp;start={}&amp;format=page-element",
        "Rings": "https://us.pandora.net/en/rings/?sz=30&amp;start={}&amp;format=page-element",
        "Necklaces": "https://us.pandora.net/en/necklaces/?sz=30&amp;start={}&amp;format=page-element",
        "Earrings": "https://us.pandora.net/en/earrings/?sz=30&amp;start={}&amp;format=page-element"
    }

    for category, url in urls.items():
        print("Total {}: {}".format(category, get_total_items(url.format(0))))



Now the intermediate variable soup is inside the function and does not clutter the global namespace. You could also now easily change the implementation of get_total_items(...) without the need to adapt the "application" code.

I also added the infamous if __name__ == "__main__":, which is basically Python's way to tell someone looking at the script: "This piece of code is supposed to be run if you use this as a script." Have a look at the official documentation or this Stack Overflow post if you want to learn more.



A more subtle change: I reorderd the imports to follow the recommendation of the official Style Guide for Python Code (often just PEP8), which is to have imports from the standard libraries first, then a blank line, and then all the third party libraries.

In general PEP8 is often worth a read, especially if you are not yet familiar with Python.