Saturday 15 August 2015

html - How do I query XHTML using python? -


I have my ASP Net Web site has created a simple test harness in Python.

To get some value for me I have to look at some HTML tags in the resulting page.

What would be the best way to do this in Python?

e.g. (Page back):

   

will appear (in std out of Python):

  Error: .....  

or

& lt; Td id = "dob" & gt; 23/3/1985 & lt; / Td>

will be displayed:

  Date of birth: 23/3/1985  

Do you want to parse XML, as you specify in the title, or HTML of your question, as you do in the text of the question? For the latter, I recommend - download it and install it, then once, when you exit soup html, you can easily with a specific ID (or other attribute) Tag: example:

  errp = soup.find (attrs = {'id': 'ErrorPanel'}) If there is no errp None: print 'error:', Errp.string  

and similar cases (easily tweakable parallels such as you are looking for non-specific attributes May include, and so on).


No comments:

Post a Comment