Skip to content

Instantly share code, notes, and snippets.

@ultrafunkamsterdam
Last active February 26, 2024 16:29
Show Gist options
  • Save ultrafunkamsterdam/6085c4c687754d8c4633b34027554903 to your computer and use it in GitHub Desktop.
Save ultrafunkamsterdam/6085c4c687754d8c4633b34027554903 to your computer and use it in GitHub Desktop.
NODRIVER - Notes to self - needs implementation asap
// add option to retrieve
// the browser devtools page for a headless tab of nodriver
def get_inspector_page(tab: uc.Tab):
s = 'http://{config.host}:{config.port}/devtools/inspector.html?ws={wsurl}'
return s.format(config=tab.browser.config, wsurl=tab.websocket_url[5:])
// proxy the following information, which is nulled whenever you override the user agent
navigator.userAgentData = {
"brands": [
{
"brand": "Not A(Brand",
"version": "99"
},
{
"brand": "Google Chrome",
"version": "121"
},
{
"brand": "Chromium",
"version": "121"
}
],
"mobile": false,
"platform": "Windows"
}
/* We could determine and construct the user agent possibly by just parsing the binary headers */
/* other option can be start the browser, get the info and restart the browser with modded info [not preferrable]
/* information from chrome binary executable:
'OriginalFilename': 'chrome.exe'
'InternalName': 'chrome_exe'
'FileDescription': 'Google Chrome'
'CompanyName': 'Google LLC'
'ProductName': 'Google Chrome'
'FileVersion': '121.0.6167.189'
'LegalCopyright': 'Copyright 2024 Google LLC. All rights reserved.'
'ProductVersion': '121.0.6167.189'
'CompanyShortName': 'Google'
'ProductShortName': 'Chrome'
*/
ua_normal = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'
ua_headless = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/121.0.0.0 Safari/537.36'
def get_info():
d = {}
from types import ModuleType
for x in dir(platform):
if x[0] == '_':
print('skipping internal key' , x); continue
v = getattr(platform, x)
if isinstance(v, ModuleType):
print('skipping ', x, ' which is moduletype')
continue
if callable(v):
try:
d[x] = v()
except Exception as e:
print('could not call ' , x, 'without arguments:',e)
continue
else:
d[x] = v
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment