try:
from selenium import webdriver
except:
!pip install selenium
!apt-get update
!apt install chromium-chromedriver
import os
from selenium import webdriver
from IPython.display import clear_output
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36')
#PROXY = "120.72.54.5:8080"
#chrome_options.add_argument('--proxy-server=http://%s' % PROXY)
wd = webdriver.Chrome('chromedriver', options=chrome_options)
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
wd.implicitly_wait(10)
clear_output()
url = input("Please enter CSDN url \n>>>>") #url = "https://blog.csdn.net/u013379032/article/details/120705889"
try:
wd.get(url)
textContent = "\n\n".join(wd.execute_script('return [...document.querySelectorAll("pre")].map(item => item.innerText)'))
except Exception as e:
print(e)
print(textContent)
wd.quit()