简体   繁体   中英

How to get the last part of user agent?

I want to get the last part of the user agent string, for example: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 Qlik

I want to get the last word, in this case, is Qlik, but it can be empty or with a longer word.

how can I do this in python?

this maybe help you

a = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 Qlik'
a.split(' ')[-1]
## 'Qlik'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM