- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestfunctionality.py
More file actions
Latest commit
39 lines (31 loc) · 1.56 KB
/
Copy pathtestfunctionality.py
File metadata and controls
39 lines (31 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
#exec(open("./testfunctionality.py").read())
importtime
#from selenium.webdriver import Chrome
fromselenium.webdriver.common.byimportBy
fromselenium.webdriver.common.keysimportKeys
fromselenium.webdriver.support.uiimportWebDriverWait
fromselenium.webdriver.supportimportexpected_conditionsasEC
fromseleniumimportwebdriver
frompyvirtualdisplayimportDisplay
importpandasaspd
data=[]
author=[]
display=Display(visible=0, size=(800, 600))
display.start()
driver=webdriver.Chrome()
driver.get('https://www.youtube.com/watch?v=un9x-DjTMT0')
wait=WebDriverWait(driver,15)
df=pd.DataFrame()
foriteminrange(10):
wait.until(EC.visibility_of_element_located((By.TAG_NAME,"body"))).send_keys(Keys.END)
time.sleep(2)
# for author in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#ytd-comment-renderer"))):
# #author.append(comment.text)
# df = df.append({'author': author}, ignore_index=True))
df=pd.concat([pd.DataFrame([author.text], columns=['Author']) forauthorinwait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#author-text")) )], ignore_index=True)
df['AuthorLink'] = [author.get_attribute('href') forauthorinwait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#author-text")) )]
df['Comment'] = [comment.textforcommentinwait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#content-text")) )]
# for comment in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#content-text"))):
# data.append(comment.text)
print(df.head())