What do I do to read html files on my pc?

Joel Goldstick joel.goldstick at gmail.com
Mon Aug 27 10:21:31 EDT 2012


On Mon, Aug 27, 2012 at 9:51 AM, mikcec82 <michele.cecere at gmail.com> wrote:
> Il giorno lunedì 27 agosto 2012 12:59:02 UTC+2, mikcec82 ha scritto:
>> Hallo,
>>
>>
>>
>> I have an html file on my pc and I want to read it to extract some text.
>>
>> Can you help on which libs I have to use and how can I do it?
>>
>>
>>
>> thank you so much.
>>
>>
>>
>> Michele
>
> Hi ChrisA, Hi Mark.
> Thanks a lot.
>
> I have this html data and I want to check if it is present a string "XXXX" or/and a string "NOT PASSED":
>
> </th>
> <td>
> <samp>
>  
>  
>  
>  
>  
> </samp>
> XXXX
> </td>
> </tr>
> <tr>
> .
> .
> .
> <th/>
> <th/>
> </tr>
> <tr align="left" style="color: red">
> <th/>
> <th>
> CODE CHECK
> </th>
> <th>
> : NOT PASSED
> </th>
> </tr>
> <tr>
> <th/>
>
> Depending on this check I have to fill a cell in an excel file with answer: NOK (if Not passed or XXXX is present), or OK (if Not passed and XXXX are not present).
>
> Thanks again for your help (and sorry for my english)
> --
> http://mail.python.org/mailman/listinfo/python-list

from your example it doesn't seem there is enough information to know
where in the html your strings will be.

If you just read the whole file into a string you can do this:

>>> s = "this is a string"
>>> if 'this' in s:
...   print 'yes'
...
yes
>>>

Of course you will be testing for 'XXXX' or 'NOT PASSED'


-- 
Joel Goldstick



More information about the Python-list mailing list