Need a Python script to generate random mobile user agents

macdonjo3

Elite Member
Jr. VIP
Joined
Nov 8, 2009
Messages
8,887
Reaction score
9,192
Does anyone have a Python script that calculates random user agents of mobile users that they could share? I'd throw some cash your way if you'd like.
 
Please, can you explain what you mean by "calculates random user agents of mobile users"
 
I mean, it generates a random user agents based on reasonable market share.

dR5z2MA
 
Here you go:

Code:
import random

uagent_list = ['Android'] * 46 + ['iOS'] * 42 + ['Symbian'] * 3 + ['Java ME'] * 3 + ['Windows'] * 2 + ['Java ME'] * 1 + ['BlackBerry'] * 1 + ['Kindle'] * 1 + ['Other'] * 1

random.choice(uagent_list)
 
Last edited:
lol wise guy here. there are more factors to a user agent than the OS.
 
Replace the OS name and percentages with your user agent list. The above is just an example of generating a weighted random number. Didn't think you needed to be spoon fed.

lol wise guy here. there are more factors to a user agent than the OS.
 
Last edited:
Code:
from fake_useragent import UserAgent

This is a good start. They have a mobile module as well, so just reverse find it, I have seen mention about it on StackExchange last week, I cant find link though.
 
Did you get what you were looking for? I'll cook you up something if not.
 
Do you want the data based on a specific country, continent, or does it matter?
 
Your usage scenario here can clarify some possible best avenues of exploration, however I see Mr.Blue solution as possibly viable, and you could certainly substitute many more user-agents, or a random query to external resource from which to pull the UA.
 
Code:
from fake_useragent import UserAgent

This is a good start. They have a mobile module as well, so just reverse find it, I have seen mention about it on StackExchange last week, I cant find link though.


Lol I thought that was a joke....
But it really exists.
 
Back
Top