Я бы хотел разобрать этот железнодорожный сайт с Python.Вот код:
<div id="ctl02_Freeform1_plcContent1_FreeformContent" class="freeform-content"><p><strong>Miles (Owned or Leased):</strong> 206 (Arizona- 181, New Mexico- 25)</p><p><strong>Interchanges:</strong> Union Pacific (Lordsburg, N.M.)</p><p><strong>Capacity:</strong> 263k</p><p><strong>Commodities:</strong> Agricultural Products, Chemicals, Copper</p><p><strong>Railcar Storage Available: </strong><a href="/customers/railcar_storage" title="Railcar Storage">No</a></p><p>Acquired by G&W in 2011</p><p>AZER was originally chartered in 1895 as the Gila Valley, Globe & Northern, with 133 route-miles between Bowie and Miami, Arizona. Today, AZER also includes a 70-mile line between Clifton, Arizona, and Lordsburg, New Mexico, that connects to the original Bowie line via trackage rights.</p><p> </p></div>
В качестве вывода я хотел бы получить содержимое полей Мили, Обмены, Емкость и Товары.
Имена категорий всегда в <strong>
теги, весь сегмент в <p>
: <p><strong>Commodities:</strong> Agricultural Products, Chemicals, Copper</p>
Как я могу получить это в BeautifulSoup?
from bs4 import BeautifulSoup
import requests
r = requests.get("https://www.gwrr.com/railroads/north_america/AZER")
data = r.text
soup = BeautifulSoup(data, 'lxml')
titel = soup.title
print(titel.string)