Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdual committed Mar 9, 2024
1 parent 07e01a1 commit a67f8df
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,30 @@ print(ua) # Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/604.1.38
```

# Customization
There are three different parameters to the generate user-agent by the certain conditions. All of the parameters are optional, and the types can be choose multiple.
**There are three different parameters to the generate user-agent by the certain conditions.**

```python
device = ('desktop', 'mobile')
platform = ('windows', 'macos', 'ios', 'linux', 'android')
browser = ('chrome', 'edge', 'firefox', 'safari')
```
All of the parameters are optional, and the types can be set multiple times by using a tuple.*

Customized user-agent generation:
## Customized user-agent generation:
```python
import ua_generator

# Sample 1
ua = ua_generator.generate(device='desktop', browser='firefox')
print(ua.text) # Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0.1) Gecko/20100101 Firefox/121.0.1
print(ua.platform) # macos
print(ua.browser) # firefox
print(ua.ch.brands) # "Not A(Brand";v="99"
# Example 1:
ua = ua_generator.generate(device='desktop', browser=('chrome', 'edge'))
print(ua.text) # Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.145 Safari/537.36
print(ua.platform) # windows
print(ua.browser) # chrome
print(ua.ch.brands) # "Not A(Brand";v="99", "Chromium";v="108", "Google Chrome";v="108"
print(ua.ch.mobile) # ?0
print(ua.ch.platform) # "macOS"
print(ua.ch.platform_version) # "14.0.1"
print(ua.ch.platform) # "Windows"
print(ua.ch.platform_version) # "10.0"

# Sample 2
# Example 2:
ua = ua_generator.generate(platform=('ios', 'macos'), browser='chrome')
print(ua.text) # Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_2 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) CriOS/119.0.6045.176 Mobile/15E148 Safari/537.36
print(ua.platform) # ios
Expand All @@ -56,7 +57,7 @@ print(ua.ch.platform) # "iOS"
print(ua.ch.platform_version) # "17.0.2"
```

You can also obtain a dictionary of headers:
# Headers
```python
ua = ua_generator.generate(browser=('chrome', 'edge'))

Expand All @@ -82,7 +83,7 @@ print(ua.headers.get())
}
```

Integrating into the [requests](https://pypi.org/project/requests/):
## Integrating into the [requests](https://pypi.org/project/requests/):
```python
import requests
import ua_generator
Expand All @@ -92,5 +93,8 @@ r = requests.get("https://httpbin.org/get", headers=ua.headers.get())
print(r.text)
```

# Issues
You can create an issue [from here](https://github.com/iamdual/ua-generator/issues) if you are experiencing a problem.

# Author
Ekin Karadeniz (iamdual@icloud.com)

0 comments on commit a67f8df

Please sign in to comment.