Skip to content

Instantly share code, notes, and snippets.

@SamadiPour
Last active July 31, 2022 22:55
Show Gist options
  • Save SamadiPour/ed0a7ee425663f710e4f88a28a578d60 to your computer and use it in GitHub Desktop.
Save SamadiPour/ed0a7ee425663f710e4f88a28a578d60 to your computer and use it in GitHub Desktop.
Deepnote selenium example
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "python",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8"
},
"kernelspec": {
"name": "python",
"display_name": "Python (Pyodide)",
"language": "python"
}
},
"nbformat_minor": 4,
"nbformat": 4,
"cells": [
{
"cell_type": "code",
"source": "%%bash\n\napt update\napt-get install -y gconf-service libasound2 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils\napt-get install -y --no-install-recommends apt-utils\nwget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb\ndpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install\nrm google-chrome-stable_current_amd64.deb",
"metadata": {},
"execution_count": null,
"outputs": []
}
]
}
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("window-size=1920,1080")
options.add_argument("--enable-javascript")
options.add_argument(
'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36'
)
driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install(), options=options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment