I am trying to get a specific header from this web
I tried this, however I can't get the categories item where the fingerprint value is located in. Can somebody help?
Currently my code is
# install chromium, its driver, and selenium
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
from seleniumwire import webdriver # Import from seleniumwire
options = webdriver.ChromeOptions()
options.set_capability(
"goog:loggingPrefs", {"performance": "ALL", "browser": "ALL"}
)
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# open it, go to a website, and get results
driver = webdriver.Chrome('chromedriver',options=options)
driver.get('https://alfagift.id/')
log_entries = driver.get_log("performance")
I try finding it in the log_entries however it's not there. I've found a java version of fingerprint sniffer https://gist.github.com/clouedoc/4a30d8e279cb486b50bdc27d65dc67bf however can't apply the same logic for in python. What should I do?
CodePudding user response:
You can access the requests made in the browser and their headers. Therefore, you can search for the fingerprint header.
fingerprintFound = False
for request in driver.requests:
hdict = dict(request.headers)
for header_key in hdict.keys():
if header_key == "fingerprint":
fingerprint = hdict[header_key]
fingerprintFound = True
break
if fingerprintFound:
break
print(fingerprint)