Skip to content

Instantly share code, notes, and snippets.

@kratsg
Created November 9, 2021 16:57
Show Gist options
  • Save kratsg/15f5ffbd2ab46d0e38a9d7ed1a75c626 to your computer and use it in GitHub Desktop.
Save kratsg/15f5ffbd2ab46d0e38a9d7ed1a75c626 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from chromedriver_py import binary_path
service = Service(binary_path)
url = 'https://twiki.cern.ch/twiki/bin/view/AtlasPublic'
with webdriver.Chrome(service=service) as driver:
driver.get(url)
driver.execute_script("addKeyword('Analysischaracteristics_Likelihood@available');")
rows = driver.find_elements('css selector', '#paperListTbody tr')
for row in rows:
elements = row.find_elements("css selector", "td")
short_title = elements[0]
links = elements[-1].find_elements("css selector", "a")
hepdata = [link.get_property('href') for link in links if link.text.lower() == 'hepdata']
print(f'{short_title.text}\n - {hepdata[0] if hepdata else "<missing link>"}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment