I need to get a title that is in an input. PYTHON web scraping

1

I need to get what it says on the title tag that is in an input:

    <div class="control-group" id="ApellidoDiv">

    <label class="control-label" for="apellidos">Apellido<span 
    class="requiredMarkApellidos"><font color="#BD4247">*</font></span></label>

    <div class="controls">
                        <input type="text" id="apellidos" name="apellidos" 
   value="" class="input-large nombre success" required="" maxlength="50" 
      title="BLANCO SERRANO" readonly="readonly" tabindex="-1">

                    </div>

                </div>

and I use html-parser I do not know how to get it I have no experience with beautifulsoup It should be noted that data is the site to which I wish to scraping.

soup = BeautifulSoup(data, "html.parser")
inputTag = soup.find(attrs={"id" : "apellidos"})
output = inputTag['title']

The following error occurs:

return self.attrs[key]
KeyError: 'title'

Please, if you help me get that name, I would be grateful.

    
asked by Diego Lopez 24.11.2017 в 21:23
source

1 answer

0

The best way to access the keys is as follows

soup = BeautifulSoup(data, 'html.parser')
inputTag = soup.find(attrs={"id" : "apellidos"})
inputTag['title']

since the same variable saves a dictionary with the html elements

    
answered by 28.12.2018 в 04:49