Skip to main content
tags editadas
Link
hkotsubo
  • 66,9mil
  • 25
  • 87
  • 170
Pergunta reaberta por hkotsubo, Icaro Martins, JeanExtreme002, Augusto Vasques, jsbueno
removeu 233 caracteres do conteúdo; título editado
Fonte Link
hkotsubo
  • 66,9mil
  • 25
  • 87
  • 170

Why does my regular expression not find any matches? Regex não pega todos os textos das tags span

I am trying to scrape a html page and I know there are htmlSei que existem parsers but since the html is not well structured I need to mix it with some regular expressionsde HTML, mas como o meu HTML não está bem estruturado, preciso usar também expressões regulares.

The html im trying to scrape looks like thisO HTML é assim:

<tr bgcolor="#CCCCCC">
<td colspan="2"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">1º 

                          Período Ideal</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Aula</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Trab.</span></font></td>
<td align="center"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CH</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CE</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CP</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">ATPA</span></font></td>
</tr>

And my regular expression looks like thisE a regex é:

r'''<span class="txt_arial_8pt_black">(.*?)</span>'''

I'm trying to get the '1º Período Ideal' bitEstou tentando pegar o texto '1º Período Ideal', but somehow it doesn't get recognized by this regular expression although some other bits of the code do get recognizedmas a regex não o reconhece, such as the 'CE'embora outros trechos sejam reconhecidos, 'CP'como 'CE', 'ATPA' which for me look the same as the bit I want to get. But I don't understand why'CP' e 'ATPA', e eu não entendo o motivo.

Can somebody help me please?

Why does my regular expression not find any matches?

I am trying to scrape a html page and I know there are html parsers but since the html is not well structured I need to mix it with some regular expressions.

The html im trying to scrape looks like this:

<tr bgcolor="#CCCCCC">
<td colspan="2"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">1º 

                          Período Ideal</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Aula</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Trab.</span></font></td>
<td align="center"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CH</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CE</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CP</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">ATPA</span></font></td>
</tr>

And my regular expression looks like this:

r'''<span class="txt_arial_8pt_black">(.*?)</span>'''

I'm trying to get the '1º Período Ideal' bit, but somehow it doesn't get recognized by this regular expression although some other bits of the code do get recognized, such as the 'CE', 'CP', 'ATPA' which for me look the same as the bit I want to get. But I don't understand why.

Can somebody help me please?

Regex não pega todos os textos das tags span

Sei que existem parsers de HTML, mas como o meu HTML não está bem estruturado, preciso usar também expressões regulares.

O HTML é assim:

<tr bgcolor="#CCCCCC">
<td colspan="2"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">1º 

                          Período Ideal</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Aula</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Trab.</span></font></td>
<td align="center"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CH</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CE</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CP</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">ATPA</span></font></td>
</tr>

E a regex é:

r'''<span class="txt_arial_8pt_black">(.*?)</span>'''

Estou tentando pegar o texto '1º Período Ideal', mas a regex não o reconhece, embora outros trechos sejam reconhecidos, como 'CE', 'CP' e 'ATPA', e eu não entendo o motivo.

Pergunta fechada como "Não é adequada para este site" por neves, Maniero
Fonte Link

Why does my regular expression not find any matches?

I am trying to scrape a html page and I know there are html parsers but since the html is not well structured I need to mix it with some regular expressions.

The html im trying to scrape looks like this:

<tr bgcolor="#CCCCCC">
<td colspan="2"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">1º 

                          Período Ideal</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Aula</span></font></td>
<td><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">Créd.<br/>

                          Trab.</span></font></td>
<td align="center"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CH</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CE</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">CP</span></font></td>
<td align="center" width="6%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="txt_arial_8pt_black">ATPA</span></font></td>
</tr>

And my regular expression looks like this:

r'''<span class="txt_arial_8pt_black">(.*?)</span>'''

I'm trying to get the '1º Período Ideal' bit, but somehow it doesn't get recognized by this regular expression although some other bits of the code do get recognized, such as the 'CE', 'CP', 'ATPA' which for me look the same as the bit I want to get. But I don't understand why.

Can somebody help me please?