Webscraping application that collects metal prices and converts them from USD to MXN real-time using BeautifulSoup from bs4 import BeautifulSoup
import requests
import re
import datetime

metal_translation = {&quot;Aluminium&quot;: &quot;Aluminio&quot;, &quot;Copper&quot;: &quot;Cobre&quot;, &quot;Zinc&quot;: &quot;Zinc&quot;, &quot;Nickel&quot;: &quot;Níquel&quot;, &quot;Lead&quot;: &quot;Plomo&quot;, &quot;Tin&quot;: &quot;Estaño&quot;,
                     &quot;Aluminium Alloy&quot;: &quot;Aleación de Aluminio&quot;, &quot;Cobalt&quot;: &quot;Cobalto&quot;, &quot;Gold*&quot;: &quot;Oro*&quot;, &quot;Silver*&quot;: &quot;Plata*&quot;,
                     &quot;Steel Scrap**&quot;: &quot;Chatarra de Acero&quot;, &quot;NASAAC&quot;: &quot;NASAAC&quot;, &quot;Steel Rebar**&quot;: &quot;Varilla de Acero&quot;}

def get_metal_values():
    names = []
    prices = []
    metals = requests.get('https://www.lme.com/').text
    soup = BeautifulSoup(metals, 'lxml')
    metal_table = soup.find(&quot;table&quot;, attrs={&quot;class&quot;: &quot;ring-times&quot;})
    metal_table_names, metal_table_prices = metal_table.tbody.find_all(&quot;th&quot;), metal_table.tbody.find_all(&quot;td&quot;)
    for name in metal_table_names:
        names.append(name.text.replace(&quot;LME &quot;, &quot;&quot;))
    for price in metal_table_prices:
        prices.append(price.text.strip())
    return names, prices

def get_peso_conversion():
    peso = requests.get('https://themoneyconverter.com/USD/MXN').text
    soup1 = BeautifulSoup(peso, 'lxml')
    conversion = soup1.find(&quot;div&quot;, class_=&quot;cc-result&quot;).text
    rate = re.search(&quot;\d{2}\.\d{4}&quot;, conversion).group()
    return rate

def get_time():
    date = datetime.datetime.now()
    time = (f'{date.day}/{date.month}/{date.year} | {date.hour}:{date.minute}')
    return time

def convert_values():
    names, prices = get_metal_values()
    rate = get_peso_conversion()
    metal_data = dict(zip(names, prices))
    for k, v in metal_data.items():
        v = (float(v.replace(&quot;,&quot;, &quot;&quot;)) * float(rate))
        v = (&quot;%.2f&quot; % v)
        k = metal_translation[k]
        print(f'{k}: {v} $')

def program_run():
    print(&quot;Metal Prices by ETHAN HETRICK&quot;)
    print(&quot;================================================&quot;)
    print(f'{get_time()} | 1 USD = {get_peso_conversion()} MXN\n')
    print(&quot;Precios de metales de London Metal Exchange: (Por tonelada métrica, *Por onza Troy)\n&quot;)
    convert_values()
    print(&quot;================================================&quot;)

program_run()
input(&quot;\nEscribe 'x' para terminar.\n&quot;)

EXAMPLE OUTPUT:

Metal Prices by ETHAN HETRICK
================================================
26/6/2020 | 18:28 | 1 USD = 23.0622 MXN

Precios de metales de London Metal Exchange: (Por tonelada métrica, *Por onza Troy)

Aluminio: 36484.40 $
Cobre: 138038.80 $
Zinc: 47438.95 $
Níquel: 293097.50 $
Plomo: 41004.59 $
Estaño: 391826.78 $
Aleación de Aluminio: 27997.51 $
NASAAC: 27444.02 $
Cobalto: 657272.70 $
Oro*: 40711.70 $
Plata*: 410.74 $
Chatarra de Acero: 6065.36 $
Varilla de Acero: 9720.72 $
================================================

Escribe 'x' para terminar.

My fiances father owns a metal recycling business in Mexico City, Mexico which requires him to do a lot of calculations when negotiating with clients. Since he was doing this by hand, I decided to automate this for him. I used London Metal Exchange, which is his preferred site to get the current prices, for the metal prices and also got the exchange rate for USD to MXN and applied that as well. I also needed to translate everything to spanish so I used a dictionary. This is my first time utilizing webscraping and the datetime module so any advice to make this program run more efficiently or make the code more concise is much appreciated!
Check for failure
metals = requests.get('https://www.lme.com/').text

should be
response = requests.get('https://www.lme.com/')
response.raise_for_status()
metals = response.text

String literals don't need parens
date = datetime.datetime.now()
time = (f'{date.day}/{date.month}/{date.year} | {date.hour}:{date.minute}')

would only need parens if it spans multiple lines.
Also, date shouldn't be called date for a couple of reasons:

it shadows datetime.date, and
it has a time, not just a date.

Finally: try using strftime rather than extracting the time's individual components to render a string.
No intermediate dict
metal_data = dict(zip(names, prices))
for k, v in metal_data.items():

The only reason you'd want to do this is if you're deeply concerned that there are duplicates, which this would remove. If there are no duplicates, then simply
for k, v in zip(names, prices):

Combine format strings
    v = (&quot;%.2f&quot; % v)
    k = metal_translation[k]
    print(f'{k}: {v} $')

can be
print(f'{metal_translation[k]}: {v:.2f}')