Skip to content

Instantly share code, notes, and snippets.

@pointofpresence
Created January 16, 2023 12:46
Show Gist options
  • Save pointofpresence/983dfeb9e1778498886ba11257bb4936 to your computer and use it in GitHub Desktop.
Save pointofpresence/983dfeb9e1778498886ba11257bb4936 to your computer and use it in GitHub Desktop.
def get_page(url):
ua = r'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
exe = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
args = f'"{exe}" --headless --disable-gpu --dump-dom --user-agent="{ua}" "{url}"'
sp = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = sp.communicate()
print(err, 'error') if err else None
return out.decode('utf-8') if out else ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment