分享个自己Python爬虫时的浏览器标识库
本人使用的Python3版本,python2未做测试 如有问题很可能出在 toObj函数上toObj函数具体参考:https://stackoverflow.com/questions/1305532/convert-Python-dict-to-object UserAgent.py class toObj(object): def __init__(self, d): for a, b in d.items(): if isinstance(b, (list, tuple)): setattr(self, a, [toObj(x) if isinstance( x, dict) else x for x in b]) else: setattr(self, a, toObj(b) if isinstance(b, dict) else b) ''' Android 设备 ''' Android = toObj({ "Xiaomi": { "Id": "Xiaomi", "Name": "小米手机", "UserAgent": "Mozilla/5.0 (Linux; U; Andr...