Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program for extracting the text from a webpage. Implement 4 functions, described below. Code should follow C++ conventions, and it should not

Write a C++ program for extracting the text from a webpage. Implement 4 functions, described below. Code should follow C++ conventions, and it should not use any libraries other than those we have discussed in class so far. 

  • string readFile(string filename)
    • This function opens the file with the given name, reads in the entirety of the file, and returns a string containing the file contents.
    • It should return the empty string if the file doesn't exist.
  • string extractParagraphs(string content)
    • This function should return all of the paragraph contents in the given HTML content, and each paragraph should be followed by two new lines (). Paragraphs in HTML start with a paragraph start tag (

      ) and end with a paragraph end tag (

      ), and the contents are between these two tags. The output should not include any of the start or end tags.
  • string removeTags(string content)
    • This function should search the given HTML content and remove all of the HTML tags. All HTML tags start with a less than sign (<) and end with a greater than sign (>), and anything that begins with a less than sign and ends with a greater than sign is an HTML tag.
  • int main()
    • main() should use the other 3 functions to read in the contents of input.html, extract all of the paragraphs in this file, remove the tags from the paragraphs, and print the result to cout.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Operating System questions