Skip to content

Commit 7600ceb

Browse files
author
Lennart Haack
authored
Merge pull request #2 from Lennolium/dev
Dev: cleanup readme
2 parents bcc7533 + 0acbb82 commit 7600ceb

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

README.md

+16-19
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ Fetches real world, up-to-date user agents for use in web scraping to avoid bot
5050
No more fake or outdated user agents, only user agents of real users.
5151
You can either get random or usage-weighted user agents. It caches
5252
the user agents locally to avoid unnecessary API calls, and refreshes them automatically every 24 hours
53-
from the public API of <a href="https://useragents.me/">useragents.me</a>.
54-
55-
<br><br>
53+
from the public API of <a href="https://useragents.me/">useragents.me</a>. <br><br>
5654

5755
[![Donate](https://img.shields.io/badge/Donate-Paypal-blue?style=flat-square&logo=paypal)](https://www.paypal.me/smogg)
5856
[![BuyMeACoffee](https://img.shields.io/badge/Buy%20me%20a-Coffee-f5d132?style=flat-square&logo=buymeacoffee)](https://buymeacoffee.com/lennolium)
@@ -83,11 +81,11 @@ from the public API of <a href="https://useragents.me/">useragents.me</a>.
8381

8482
## Features
8583

86-
- __Up-to-date:__ No fake or outdated user agents, only real world data. Refreshed every 24 hours.
84+
- __Up-to-date:__ No fake or outdated user agents. `Only real world data`, refreshed every 24 hours.
8785
- __Wide Support:__ User Agents for Windows, macOS, Linux, Android and iOS devices: Google Chrome, Firefox, Safari, Edge, Opera, Whale and QQ browsers.
8886
- __Lightweight:__ Designed to consume minimal system resources and caches user agents locally.
8987
- __Simple:__ Easy to use and understand with a clean and simple API.
90-
- __Compatible:__ Supports Python 3.8 and above. Runs on Windows, macOS and Linux.
88+
- __Compatible:__ Supports `Python 3.8 and above`. Runs on Windows, macOS and Linux.
9189
- __Privacy:__ Protects the user by not collecting or sending any personal data.
9290
- __Open Source:__ Provides transparency and allows community contributions for continuous development.
9391

@@ -118,31 +116,29 @@ Just import the package and use the convenience functions. For more advanced usa
118116

119117
sua.get(num=2, force_cached=True, mobile=True)
120118
# [UserAgent('Mozilla/5.0 (Android ...'), UserAgent('Mozilla/5.0 (iPhone; ...')]
119+
121120
sua.get_list() # Returns a list of 45 or 23 (desktop/mobile) user agents as strings.
122121
# ['Mozilla/5.0 ...', 'Mozilla/5.0 (iPhone ...', 'Mozilla/5.0 (iPhone ...', ...]
122+
123123
sua.get_dict() # Returns a dictionary with all desktop and mobile user agents.
124124
# {'desktop': ['Mozilla/5.0 ...', ...] 'mobile': ['Mozilla/5.0 (iPhone ...', ...]}
125125
```
126126
&nbsp;
127127

128128
#### Advanced Usage
129129

130-
Import the package.
130+
Import the package and initialize the UserAgents class to set custom settings (optional, see [Settings and Parameters](#settings-and-parameters) for details).
131131
```python
132-
from simple_useragent import UserAgents, get, get_list, get_dict, parse
133-
```
134-
&nbsp;
132+
import simple_useragent as sua
135133

136-
Initialize the class to set custom settings.
137-
```python
138-
user_agents = UserAgents(max_retries=3, timeout=5, cache_duration=86400, cache_location='var/cache/simple-useragent')
134+
simple_ua = sua.UserAgents(max_retries=3, timeout=5, cache_duration=86400, cache_location='example/path/to/folder')
139135
```
140136
&nbsp;
141137

142138
Fetching User Agents.
143139
```python
144140
# Fetch a specified number of random mobile user agent instances.
145-
user_agents.get(num=2, shuffle=True, mobile=True)
141+
simple_ua.get(num=2, shuffle=True, mobile=True)
146142
# [UserAgent('Mozilla/5.0 (iPhone ...'), UserAgent('Mozilla/5.0 (iPhone; ...')]
147143
```
148144
&nbsp;
@@ -151,17 +147,18 @@ You can also use the convenience functions to get user agents without initializi
151147
```python
152148
get(num=2, force_cached=True, mobile=True)
153149
# [UserAgent('Mozilla/5.0 (Android ...'), UserAgent('Mozilla/5.0 (iPhone; ...')]
150+
154151
get_list() # Returns a list of 45 or 23 (desktop/mobile) user agents as strings.
155152
# ['Mozilla/5.0 ...', 'Mozilla/5.0 (iPhone ...', 'Mozilla/5.0 (iPhone ...', ...]
153+
156154
get_dict() # Returns a dictionary with all desktop and mobile user agents.
157155
# {'desktop': ['Mozilla/5.0 ...', ...] 'mobile': ['Mozilla/5.0 (iPhone ...', ...]}
158-
159-
160156
```
161157
&nbsp;
162158

163-
The instance offers attributes for the user agent properties. You can also parse a custom string directly to the UserAgent class.
159+
The instance offers attributes for the user agent properties.
164160
```python
161+
# Parse a custom string directly to the UserAgent class and access its attributes.
165162
obj = parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36')
166163
obj.string # 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit ...'
167164
obj.browser # 'Chrome', 'Firefox', 'Safari', 'Edge', 'IE', 'Opera', 'Whale', 'QQ Browser', 'Samsung Browser', 'Other'
@@ -173,13 +170,12 @@ The instance offers attributes for the user agent properties. You can also parse
173170
obj['os_version'] # '10'
174171
obj['os_version_minor'] # '0'
175172
obj['mobile'] # True / False
176-
177173
```
178174
&nbsp;
179175

180176
#### Settings and Parameters
181177

182-
You can set custom settings when initializing the class.
178+
You can set custom preferences when initializing the class with `UserAgents(max_retries=3)`.
183179

184180
- __max_retries:__ The maximum number of retries to reach the API, before falling back to local cache (default: _3_).
185181
- __timeout:__ The timeout in seconds for the API request (default: _5_).
@@ -188,7 +184,8 @@ You can set custom settings when initializing the class.
188184

189185
&nbsp;
190186

191-
Most functions can take the following parameters:
187+
The functions can take the following parameters:
188+
192189
- __num:__ The number of user agents to fetch (default: _None_ = gets you all user agents available).
193190
- __mobile:__ Fetch mobile or desktop user agents (default: _False_ = desktop).
194191
- __shuffle:__ Whether to shuffle/randomize the order of user agents (default: _False_ = ordered by usage).

0 commit comments

Comments
 (0)