Ask a Question

how to get the data from HTML page and use that as a string

678
Regular Contributor

how to get the data from HTML page and use that as a string

i have a HTML page of 10 pages, i need to get the Data of only 5th page to a String 

 

 

4 REPLIES 4
richie
Community Hero

Hey @678 

 

Could you supply a little more background and the use case?

 

saying "I need to extract some data at page 5 of a 10 page .html file" needs a little drilling down to resolve the ambiguities!

 

That said - I once had to extract some html which was a .json attribute so I just used the inbuilt xml parser available via the out of the box functionality.

 

Cheers,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
678
Regular Contributor

I am using following peice to read the complete html page but it a very long HTML page

 


def filename = "C:/Users/ProjectReport.html"

 

// read all the content of the file into a single string
File fh1 = new File(filename)
def report = fh1.getText('UTF-8')

 

but i need the part of the page in between lines like 

 

Tag line <TestSuite Results>  to  Tag line <end of TestSuite Results>

TanyaYatskovska
SmartBear Alumni (Retired)

Hi @678,

 

As far as I understand, you want to parse some report. Is it a ReadyAPI report?

 


@678 wrote:

Tag line <TestSuite Results>  to  Tag line <end of TestSuite Results>


It's not an HTML tag. This makes me think that it will be much easier if you export your report to the XML format. By using a groovy script, you can easily extract the needed node from an XML file by using XPath. Please read the following article for more information:

https://support.smartbear.com/readyapi/docs/testing/scripts/samples/nodes.html

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



678
Regular Contributor

Yes, its an ReadyAPI Complete Project report but i need only TestSuite Results should capture from the report

that i am going to use to send an email as body 

cancel
Showing results for 
Search instead for 
Did you mean: