@@ -22,7 +22,9 @@ def initialize(info = {})
22
22
Opt ::Proxies ,
23
23
OptInt . new ( 'MAX_PAGES' , [ true , 'The maximum number of pages to crawl per URL' , 500 ] ) ,
24
24
OptInt . new ( 'MAX_MINUTES' , [ true , 'The maximum number of minutes to spend on each URL' , 5 ] ) ,
25
- OptInt . new ( 'MAX_THREADS' , [ true , 'The maximum number of concurrent requests' , 4 ] )
25
+ OptInt . new ( 'MAX_THREADS' , [ true , 'The maximum number of concurrent requests' , 4 ] ) ,
26
+ OptString . new ( 'USERNAME' , [ false , 'The HTTP username to specify for authentication' ] ) ,
27
+ OptString . new ( 'PASSWORD' , [ false , 'The HTTP password to specify for authentication' ] )
26
28
] , self . class
27
29
)
28
30
@@ -34,8 +36,6 @@ def initialize(info = {})
34
36
OptString . new ( 'UserAgent' , [ true , 'The User-Agent header to use for all requests' ,
35
37
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
36
38
] ) ,
37
- OptString . new ( 'BasicAuthUser' , [ false , 'The HTTP username to specify for basic authentication' ] ) ,
38
- OptString . new ( 'BasicAuthPass' , [ false , 'The HTTP password to specify for basic authentication' ] ) ,
39
39
OptString . new ( 'HTTPAdditionalHeaders' , [ false , "A list of additional headers to send (separated by \\ x01)" ] ) ,
40
40
OptString . new ( 'HTTPCookie' , [ false , "A HTTP cookie header to send with each request" ] ) ,
41
41
OptBool . new ( 'SSL' , [ false , 'Negotiate SSL for outgoing connections' , false ] ) ,
@@ -118,8 +118,9 @@ def run
118
118
:info => ""
119
119
} )
120
120
121
- if datastore [ 'BasicAuthUser' ]
122
- t [ :http_basic_auth ] = [ "#{ datastore [ 'BasicAuthUser' ] } :#{ datastore [ 'BasicAuthPass' ] } " ] . pack ( "m*" ) . gsub ( /\s +/ , '' )
121
+ if datastore [ 'USERNAME' ] and datastore [ 'USERNAME' ] != ''
122
+ t [ :username ] = datastore [ 'USERNAME' ] . to_s
123
+ t [ :password ] = datastore [ 'PASSWORD' ] . to_s
123
124
end
124
125
125
126
if datastore [ 'HTTPCookie' ]
@@ -278,9 +279,8 @@ def crawler_options(t)
278
279
opts [ :cookies ] = t [ :cookies ]
279
280
end
280
281
281
- if t [ :http_basic_auth ]
282
- opts [ :http_basic_auth ] = t [ :http_basic_auth ]
283
- end
282
+ opts [ :username ] = t [ :username ] || ''
283
+ opts [ :password ] = t [ :password ] || ''
284
284
285
285
opts
286
286
end
0 commit comments