0

I have this tag in my HTML code

<td> Open </td>

and another one:

<td> Prévu </td>

I use (soup is the HTML page)

soup.find(text='Open')

and it is found but when it comes to use

 soup.find(text='Prévu')

I get no result (None object).

The goal of finding these two keywords is not the search itself but to see whether a specific element in a table has value Open and Prévu (the table is misformatted, so I can't really rely on a fixed structure to match a specific cell).

I guess the problem comes from the accented letter. I also tried with

&egrave;
&eacute;

but same result.

Any clue? Thanks in advance

dragonmnl
  • 14,578
  • 33
  • 84
  • 129

1 Answers1

2

Use unicode to solve the problem:

soup.find(text=u'Prévu')
CodeNinja
  • 1,168
  • 2
  • 14
  • 27
  • thanks for you answer. I just tried but nothing actually changes. also, I'm using BeatifulSoup4 on Python3 which supports only unicode – dragonmnl Dec 02 '14 at 10:23
  • Also ensure that your source encoding matches the assumed encoding. For example: Set the encoding of the source file to UTF-8 and set `# coding=UTF-8` in the head of your source files – Alastair McCormack Feb 15 '15 at 23:22