Skip to content

Instantly share code, notes, and snippets.

@nopium
Created November 1, 2023 13:07
Show Gist options
  • Save nopium/002f59ffb7ec2a3afcc29a3b87622a90 to your computer and use it in GitHub Desktop.
Save nopium/002f59ffb7ec2a3afcc29a3b87622a90 to your computer and use it in GitHub Desktop.
# pip install selenium bs4
url = 'https://www.amphenol-cs.com/millipacs-10127112102lf.html'
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver import ChromeOptions
options = webdriver.ChromeOptions()
options.add_argument('--headless=new')
options.add_argument('--disable-gpu')
options.add_argument("--window-size=1920,1080")
options.add_argument('user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36')
driver = webdriver.Chrome(options)
driver.get(url)
html_content = driver.page_source
soup = BeautifulSoup(html_content, 'html.parser')
desc = soup.find('div', class_='full-desc')
if desc:
print( desc.contents[0] )
else:
print( 'Fail' )
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment