File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change 2323//! limitations under the License.
2424
2525use rand:: Rng ;
26+ use regex:: Regex ;
2627use scraper:: { Html , Selector } ;
27- use select:: document:: Document ;
28- use select:: predicate:: Name ;
2928
3029use goose:: GooseState ;
3130use goose:: goose:: { GooseTaskSet , GooseClient , GooseTask } ;
@@ -80,23 +79,19 @@ fn drupal_loadtest_front_page(client: &mut GooseClient) {
8079 // Grab some static assets from the front page.
8180 match response {
8281 Ok ( r) => {
83- // Grab all src values from image tags.
84- match Document :: from_read ( r) {
85- Ok ( d) => {
86- d. find ( Name ( "img" ) )
87- . filter_map ( |n| n. attr ( "src" ) )
88- . for_each ( |x| {
89- // @TODO: once we're done comparing Goose to Locust, improve this
90- // to do a better job of matching local assets
91- if x. contains ( "/misc" ) || x. contains ( "/themes" ) {
92- let _response = client. set_request_name ( "static asset" ) . get ( x) ;
93- }
94- } ) ;
82+ match r. text ( ) {
83+ Ok ( t) => {
84+ let re = Regex :: new ( r#"src="(.*?)""# ) . unwrap ( ) ;
85+ for url in re. captures_iter ( & t) {
86+ if url[ 1 ] . contains ( "/misc" ) || url[ 1 ] . contains ( "/themes" ) {
87+ let _response = client. set_request_name ( "static asset" ) . get ( & url[ 1 ] ) ;
88+ }
89+ }
9590 } ,
9691 Err ( e) => {
9792 eprintln ! ( "failed to parse front page: {}" , e) ;
9893 client. set_failure ( ) ;
99- }
94+ } ,
10095 }
10196 } ,
10297 Err ( e) => {
You can’t perform that action at this time.
0 commit comments