📄 screenscraping.cpp
字号:
// Tutorial 19: ScreenScraping.cpp
// Search an HTML code string for an item and display its price
// converted from euros to American dollars.
#include <iostream> // required to perform C++ stream I/O
#include <iomanip> // required for parameterized stream manipulators
#include <string> // required to access string functions
#include <cstdlib> // required for the atof function
using namespace std; // for accessing C++ Standard Library members
// function prototypes
void displayMenu( string & );
double getRate();
double getPrice( string &, string &, double );
// function main begins program execution
int main ()
{
return 0; // indicate that program ended successfully
} // end function main
// prompt the user for a search item and return the appropriate
// search string
void displayMenu( string &searchText )
{
// define local variable to store user selection from the menu
int selection = 0;
while ( selection < 1 || selection > 4 )
{
// display the menu
cout << "\nWhich item would you like to search for?\n";
cout << "1 - Antique Rocking Chair" << endl;
cout << "2 - Silver Teapot" << endl;
cout << "3 - Gold Pocket Watch" << endl;
cout << "4 - Exit the application" << endl;
cout << "Enter selection: ";
cin >> selection; // retrieve the selection
// assign the appropriate search string to searchText
switch ( selection )
{
case 1:
searchText = "Antique Rocking Chair";
break;
case 2:
searchText = "Silver Teapot";
break;
case 3:
searchText = "Gold Pocket Watch";
break;
case 4:
searchText = "";
cout << endl;
break;
default: // if invalid option was selected
searchText = "";
cout << "Error: Please enter a valid selection."
<< endl;
} // end switch
} // end while
} // end function displayMenu
// get currency conversion rate
double getRate()
{
double rate; // stores the conversion rate
// prompt the user for and input the conversion rate
cout << "Enter conversion rate: ";
cin >> rate; // get the rate
return rate; // return a copy of the rate
} // end function getRate
// find the price for the selected item
double getPrice( string &htmlText, string &searchText,
double conversionRate )
{
} // end function getPrice
/**************************************************************************
* (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -