Так что я использую Beautifulsoup на Python, чтобы попытаться взять html-информацию со страницы.
from bs4 import BeautifulSoup
page = requests.get('http://www.meteo.gr/cf.cfm?city_id=14') #sending the request to take the html file.
soup = BeautifulSoup(page.content, 'html.parser') #creating beautifulSoup object of the html code.
four_days = soup.find("div", {"class": "content"})#PINPOINTING to the section that i want to focus (the outer).
#Selecting specific elements , having as my base the seven_day.
periods_times = [p.get_text(strip=True) for p in four_days.select(".perhour .fulltime")]
anemos = [sd.get_text("|", strip=True) for sd in four_days.select(".anemosfull")]
temps = [t.get_text("|", strip=True) for t in four_days.select(".temperature .tempcolorcell") ]
prognosi_ouranou =[pk.get_text("|", strip=True) for pk in four_days.select(".phenomenafull .phenomeno-name") ]
drastiriotita_kounoupion =[po.get_text("|", strip=True) for po in four_days.select(".someclass .tr > title") ]
#creating a Data Frame via pandas to print it TABLE-like.
import pandas as pd
weather = pd.DataFrame({
"drastiriotita_kounoupion": drastiriotita_kounoupion})
print weather
Я получаю ошибку, когда пытаюсь что-то подобное. Я знаю, как использовать 2 класса в селекторе, но информация, которую я хочу получить с сайта, находится внутри одного класса, и этот класс содержит информацию в элементе.
Любое предложение.
Спасибо
Я пытался найти подобные примеры в документации, но ни один из них на самом деле не охватывает мой вопрос.
[simmilar пример]
css_soup.select("p.strikeout.body")