Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. string html;
  2. //(Some code that reads into a big string)
  3.  
  4. string delimiter( "<p class="wx-temp">" );
  5. vector<int> temperatures;
  6.  
  7. size_t pos = html.find_first_of(delimiter);
  8. while( pos != string::npos )
  9. {
  10. // Skip past the tag (to the temperature)
  11. pos += delimiter.size();
  12. if( pos >= html.size() ) break;
  13.  
  14. // Extract it (C-style) and chuck it into the vector.
  15. int temperature = atoi( html.c_str() + pos );
  16. temperatures.push_back(temperature);
  17.  
  18. // If you want to stop after the first 10:
  19. if( temperatures.size() == 10 ) break;
  20.  
  21. // Find the next tag
  22. pos = html.find_first_of(delimiter, pos);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement