[Python] I tried to graph the top 10 eyeshadow rankings

Overview

You can see the ranking of cosmetics on the cosmetics site LIPS. This time I got the eyeshadow ranking, I would like to make a graph with the product name on the vertical axis and the star rating on the horizontal axis. The flow from top to bottom is the ranking.

Complete

code

import requests
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt

#Scraping LIPS site
urlName = "https://lipscosme.com/"
url = requests.get(urlName)
url.raise_for_status()
bs = BeautifulSoup(url.text, "html.parser")

url_list = []

# url_The list contains URLs for eyeshadow, foundation, lipstick, and lotion
#This time, only the eye shadow is graphed
for i in bs.select('a.ranking-products-list__more-link'):
    url_list.append(urlName + i.get('href'))
url_list.pop() #Deleted the URL of the lotion
url_list.pop() #Remove lipstick URL
url_list.pop() #Remove foundation URL

name_list = []
start_list = []
for i in url_list:
    url_temp = requests.get(i)
    url_temp.raise_for_status()
    bs_temp = BeautifulSoup(url_temp.text, "html.parser")

    for j in bs_temp.select('div.ProductListArticle'):
        for k in j.select('div.ProductListArticle__product'):
            for k2 in k.select('h2.ProductListArticle__productTitle-productName'):
                name_list.append(k2.text)
            for k3 in k.select('span.ratingStar__num'):
                start_list.append(k3.text)  

#Graph creation
#Top 10
start_list = start_list[:10]
name_list = name_list[:10]
#Reverse order to display ranking from top to bottom
start_list.reverse()
name_list.reverse()
labels = [float(i) for i in start_list] #Put a star rating on the label next to it
height = name_list #Put the name of the eyeshadow on the vertical label
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.barh(height,labels,height = 0.5)

plt.xticks(rotation=90)
plt.title('10 eyeshadow rankings', fontsize=15)
plt.ylabel("Cosmetic name", fontsize=15)
plt.xlabel("Star rating", fontsize=15)
plt.tick_params(labelsize=10)

plt.show()

Summary

I think that the star rating goes down as you go down from the first place in the ranking. The result was that the stars did not change much.

I hope you can refer to this graph when you buy eyeshadow!

Next time, let's make a graph of foundation and other cosmetics.

Recommended Posts

[Python] I tried to graph the top 10 eyeshadow rankings
I tried to graph the packages installed in Python
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
I tried to solve the problem with Python Vol.1
I tried to complement the knowledge graph using OpenKE
I tried to summarize the string operations of Python
I tried to touch Python (installation)
I tried to move the ball
I tried to estimate the interval.
[Python] I tried to visualize the follow relationship of Twitter
I tried to implement the mail sending function in Python
I tried to enumerate the differences between java and python
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
I tried to divide the file into folders with Python
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried to solve the ant book beginner's edition with python
I tried to summarize the umask command
I tried to implement permutation in Python
I tried to recognize the wake word
I tried to implement PLSA in Python 2
Python3 standard input I tried to summarize
I tried to implement ADALINE in Python
I tried to estimate the pi stochastically
I tried to touch the COTOHA API
I tried to implement PPO in Python
Python: I tried the traveling salesman problem
[Python] I tried to calculate TF-IDF steadily
I tried to touch Python (basic syntax)
I tried to improve the efficiency of daily work with Python
I tried the Python Tornado Testing Framework
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
I tried to refer to the fun rock-paper-scissors poi for beginners with Python
When I tried to run Python, it was skipped to the Microsoft Store
Python -I tried to restore the dictionary comprehensive notation to its original form-
[Python] I tried to analyze the pitcher who achieved no hit no run
I tried to get the authentication code of Qiita API with Python.
(Python) I tried to analyze 1 million hands ~ I tried to estimate the number of AA ~
I tried to verify and analyze the acceleration of Python by Cython
I tried to streamline the standard role of new employees with Python
I tried to get the RSS of the top song of the iTunes store automatically
I tried to get the movie information of TMDb API with Python
I tried to display the altitude value of DTM in a graph
I tried to analyze the New Year's card by myself using python
I tried "smoothing" the image with Python + OpenCV
I tried web scraping to analyze the lyrics.
[Python] I tried substituting the function name for the function name
vprof --I tried using the profiler for Python
I tried "differentiating" the image with Python + OpenCV
I tried to optimize while drying the laundry
I tried to save the data with discord
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
I tried to touch the API of ebay
I tried to get CloudWatch data with Python
I tried python programming for the first time.
I tried to correct the keystone of the image
I tried to output LLVM IR with Python
I tried using the Datetime module by Python