Python html div class
<p>I'm trying to write a simple program which saves the values of a table in a matrix (later I want to send the matrix to a database).</p>

<p>Here is my code:</p>

<pre><code>pfad = "https://business.facebook.com/ads/manager/account/ads/?act=516059741896803&amp;pid=p2&amp;report_spec=6056690557117&amp;business_id=401807279988717"
html = urlopen(pfad)
r=requests.get(pfad)
soup = BeautifulSoup(html.read(),'html.parser')
mydivs = soup.findAll("div", { "class" : "ellipsis_1ha3" })

# no output:
for div in mydivs: 
    if (div["class"]=="ellipsis_1ha3"):
        print div
# output: []
print(mydivs)
</code></pre>

<p>I want the values inside of the <code>div</code>s with class <code>ellipsis _1ha3</code>, but I don't know why it doesn't work. Can anyone help me?</p>

<p>Here is an example html which is like the original</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;style&gt;

        .ellipsis_1ha3 
        {
            width: 100px;
            border: 1px solid black;
        }
        .a      
        {
            width: 100px;
            border: 1px solid black;
        }

    &lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div&gt;
    &lt;div style="display: inline-flex;"&gt;
        &lt;div class="a"&gt;Purchase&lt;/div&gt;
        &lt;div class="a"&gt;Clicks&lt;/div&gt;
    &lt;/div&gt;
    &lt;/br&gt;
    &lt;div style="display: inline-flex;"&gt;
        &lt;div class="ellipsis_1ha3"&gt;20&lt;/div&gt;
        &lt;div class="ellipsis_1ha3"&gt;30&lt;/div&gt;
    &lt;/div&gt;
    &lt;/br&gt;
    &lt;div style="display: inline-flex;"&gt;
        &lt;div class="ellipsis_1ha3"&gt;10&lt;/div&gt;
        &lt;div class="ellipsis_1ha3"&gt;50&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>SECOND EXAMPLE</p>

<pre><code>pfad = "http://www.bundesliga.de/de/liga/tabelle/"
html = urlopen(pfad)
soup = BeautifulSoup(html.read(),'html.parser')
mydivs = soup.findAll('div', { 'class' : 'wwe-cursor-pointer' })
for div in mydivs: 
    if ("wwe-cursor-pointer" in div["class"]):
        print div
</code></pre>

<p>Try using <code>lxml</code> and xpath expressions to pull out the relevant information.  Beautifulsoup is built on lxml, I believe. Assuming you loaded the document into a string called <code>html_string</code>.</p>

<pre><code>from lxml import html

h = html.fromstring(html_string)

h.xpath('//div[@class="ellipsis_1ha3"]/node()')
#output:
['20', '30', '10', '50']
</code></pre>

python html beautifulsoup