title: How can I get text from only <p> and <h2> tags when finding element by class with selenium and python?
body: <p>I am trying to get the text only from the h2 and the first p tag. I've been using class name to find the div and the output gives me all of the text in the div (obviously).</p>
  <p>Here is the HTML:</p>
  <pre><code>&lt;div class=&quot;horoscope-content&quot;&gt;
  &lt;h2&gt; Today's Libra Horoscope for January 27, 2022 &lt;span class=&quot;today-badge&quot;&gt;TODAY&lt;/span&gt;&lt;/h2&gt;
  &lt;p&gt;Go with the flow, Libra. If you find that a situation isn't unfolding the way you'd like it to, take it as a sign to back off. Swimming upstream is hard work, so use your energy more efficiently by exploring different options. When you step back from a stressful situation, circumstances could turn around. Lighten up by considering other possibilities or talking it through with a helpful friend.&lt;/p&gt;            
  &lt;p&gt;What's in the stars for you tomorrow? &lt;a href=&quot;/horoscopes/daily/libra/friday&quot;&gt;Read it now&lt;/a&gt;.&lt;/p&gt;
  &lt;div class=&quot;dropdown-inline&quot;&gt;Read the &lt;b&gt;daily horoscope&lt;/b&gt; for another zodiac sign:&lt;div id=&quot;dropdown_below_horoscope_dropdown&quot; class=&quot;dropdown&quot;&gt;
  </code></pre>
  <p>Here is the code I'm using:</p>
  <pre><code>libra_content = driver.find_elements(By.CLASS_NAME, 'horoscope-content')
  </code></pre>
  <p>I assume the answer is to use xpath but I can't figure out how to include both tags. Do I need to use two separate lines of code to do it or can I combine both into one?</p>