fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. bool getKey(const string &keyval, size_t start, size_t& second, string &value);
  7.  
  8. int main()
  9. {
  10. int count = 0;
  11. string url = "https://www.google.com/search?q=where+food+near+me&oq=where+food+near+me&aqs=chrome..69i57j0l5.8995j0j9&sourceid=chrome&ie=UTF-8";
  12. string value;
  13. size_t res = 0;
  14. while ((count < 20) && getKey(url, res, res, value)) {
  15. cout << value << endl;
  16. ++count;
  17. }
  18.  
  19. return 0;
  20. }
  21.  
  22. bool getKey(const string &keyval, size_t start, size_t& second, string &result)
  23. {
  24. result = "";
  25.  
  26. if (start == 0) {
  27. if ((start = keyval.find('?')) == string::npos)
  28. return false;
  29. ++start;
  30. }
  31. else if (start >= keyval.size())
  32. return false;
  33.  
  34. size_t end = keyval.find('&', start);
  35. if (end != string::npos) {
  36. result = keyval.substr(start, end - start);
  37. second = end + 1;
  38. }
  39. else {
  40. result = keyval.substr(start);
  41. second = keyval.size();
  42. }
  43. return true;
  44. }
  45.  
Success #stdin #stdout 0s 4484KB
stdin
Standard input is empty
stdout
q=where+food+near+me
oq=where+food+near+me
aqs=chrome..69i57j0l5.8995j0j9
sourceid=chrome
ie=UTF-8