Look for text with BeautifulSoup in a web page with multiple html tags?
Question: Thanks for your help.

I am trying to extract text from a web page using BeautifulSoup and Python. I
have done it lots of times with different web pages and always got the
information I needed, but this time the html source code from the web page has
a lot of scripts and other stuff. This is one of the pages I want to extract
information from:

<http://www.cofemersimir.gob.mx/mirs/38656>

The problem with this web page is that it has a lot of iframe tags, each of
which has an opening tag (html) and a closing one (/html) and I can extract
information from the main page but not the information hidden on the second
tab and under the hidden display text area.

For example, when I look for:

    
    
    soup.find('div',{'name':"Pregunta_452Respuesta_826"})
    

I can get the information I need, but if I look for:

    
    
    soup.find('div',{'name':"Pregunta_459Respuesta_841"})
    

I get a None answer even tough I can see the information in the html source
code.

Please help me...

Thanks!


Answer: Using the following code:

    
    
    import urllib2
    from bs4 import BeautifulSoup
    
    data = urllib2.urlopen('http://www.cofemersimir.gob.mx/mirs/38656')
    
    data = data.read()
    
    soup = BeautifulSoup(data, 'html.parser')
    
    print soup.find('div',{'name':"Pregunta_459Respuesta_841"})
    

I am getting back:

    
    
    <div class="RespMir" name="Pregunta_459Respuesta_841"> <p style="text-align: justify">
                        La regulación de mérito tiene como propósito dar a conocer el cambio de domicilio y horarios de atención de la Delegación de la Secretaría de Relaciones Exteriores en Ciudad Juárez, Chihuahua.
                      </p> </div>
    

