HTP. - HTTP Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > HTP. - Command > !HTP-General - General HTTP operations and utilities > !Utility - Helper functions for HTTP operations (string conversion, proxy toggling) >

HTP. - HTTP Operations

HTP.GetUA

Previous Top Next


SPR Script Language

 

HTP.GetUA

Returns a User-Agent string based on a specified index.

 

Intention

 

The HTP.GetUA command fetches a User-Agent string to identify your HTTP requests in SPR as coming from a specific browser or device. You provide an index number (e.g., $$INDEX as "30" for Chrome), and it returns the matching User-Agent string, optionally storing it in $$RET. If the index is less than 1, it randomly picks one from 1 to 30. This is useful for mimicking different clients in requests handled by HTP.Request or HTP.ReqShort.

 

It’s like choosing a disguise for your robot’s web requests—HTP.GetUA lets you pick a browser identity (e.g., Chrome, Safari) to match server expectations or test different client behaviors.

 

Illustration

🎭 Pick a Browser: HTP.GetUA|30|$$UA gets Chrome’s User-Agent into $$UA.
🤖 Random Choice: HTP.GetUA|0 picks a random one if you’re unsure!

 

Syntax

 

HTP.GetUA|$$INDEX[|$$RET]

 

Parameter Explanation

 

P1 - $$INDEX - (Variable, Numeric)

The index number selecting a User-Agent string (e.g., $$INDEX as "30"). Must be 1-30 for specific agents; if less than 1, a random index from 1-30 is chosen. Required.

 

P2 - $$RET - (Variable, String, Optional)

The variable to store the User-Agent string (e.g., $$RET). If omitted, the string is returned but not stored.

 

User-Agent Index List:

 

1 - Safari 16.1 (macOS): Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15

2 - Firefox 115 (Windows): Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0

3 - Edge 116 (Windows): Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edge/116.0.1938.69

4 - Firefox 115 (Ubuntu): Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:115.0) Gecko/20100101 Firefox/115.0

5 - Chrome 116 (macOS): Mozilla/5.0 (Macintosh; Intel Mac OS X 13_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

6 - Safari 16.0 (iPhone): Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1

7 - Safari 16.0 (iPad): Mozilla/5.0 (iPad; CPU OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1

8 - Chrome 116 (Android, Samsung): Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.95 Mobile Safari/537.36

9 - Chrome 116 (Android, Pixel): Mozilla/5.0 (Linux; Android 13; Pixel 6 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.95 Mobile Safari/537.36

10 - Firefox 114 (Windows): Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:114.0) Gecko/20100101 Firefox/114.0

11 - Safari 14.0 (macOS): Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15

12 - Chrome 113 (Windows 7): Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36

13 - Chrome 113 (macOS): Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36

14 - Chrome 113 (Windows 8.1): Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36

15 - IE 11 (Windows 7): Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko

16 - IE 8 (Windows Vista): Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)

17 - Firefox 40 (Windows XP): Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0

18 - Safari 5.0 (PowerPC macOS): Mozilla/5.0 (Macintosh; PPC Mac OS X 10_5_8) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16

19 - Opera 12.18 (Windows 7): Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.18

20 - Android 4.0 Browser (HTC): Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

21 - Safari 10.0 (iPhone): Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14E5239e Safari/602.1

22 - Chrome 113 (Android, Samsung): Mozilla/5.0 (Linux; Android 9; SM-J260F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Safari/537.36

23 - Safari 13.1 (iPhone): Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Mobile/15E148 Safari/604.1

24 - Firefox 4.0 (Windows Vista): Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0

25 - Firefox 4.0 (macOS): Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0

26 - IE 10 (Windows 7): Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)

27 - Firefox 64 (Linux): Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0

28 - IE 11 (Windows 7): Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko

29 - Chrome 114 (Linux): Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

30 - Chrome 116 (Windows): Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Other (default) - Smart AI Package Robot (if index > 30)

 

Examples

 

'***********************************

' HTP.GetUA - Sample 1: Get Chrome User-Agent

'***********************************

HTP.GetUA|30|$$UA

MBX.Chrome UA: $$UA

MBX.Ready

'

'***********************************

' HTP.GetUA - Sample 2: Random User-Agent

'***********************************

HTP.GetUA|0|$$UA

PRT.Random UA: $$UA

MBX.Ready

'***********************************

' HTP.GetUA - Sample 3: Use in Request

'***********************************

HTP.GetUA|6|$$UA

HTP.Request|GET|https://api.example.com|||0|0|6|$$RES

PRT.Response as iPhone: $$RES

MBX.Ready

'

 

Remarks

 

- Use with HTP.Request or HTP.ReqShort by passing the index as the User-Agent parameter.

- Random selection (index < 1) varies each call, useful for testing.

- Indices 1-30 cover modern and older browsers; see list for details.

 

Limitations

 

- Limited to 30 predefined User-Agents; indices > 30 return a default string.

- No custom User-Agent input; use predefined indices only.

- Random selection (index < 1) is unpredictable, not repeatable.

 

See also:

 

HTP.Request

HTP.ReqShort

HTP.SetDef