You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
# import libraries
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.keys import Keys
|
|
import os
|
|
import time
|
|
import datetime
|
|
|
|
today = datetime.date.today()
|
|
|
|
# get the url from the terminal
|
|
url = input("Enter instance.social url (include https:// etc.): ")
|
|
|
|
# Tell Selenium to open a new Firefox session
|
|
# and specify the path to the driver
|
|
driver = webdriver.Firefox(executable_path=os.path.dirname(os.path.realpath(__file__)) + '/geckodriver')
|
|
|
|
# Implicit wait tells Selenium how long it should wait before it throws an exception
|
|
driver.implicitly_wait(10)
|
|
driver.get(url)
|
|
time.sleep(3)
|
|
|
|
d = 1
|
|
|
|
while True:
|
|
|
|
driver.find_element_by_css_selector('a.list-group-item:nth-child(%d)'%d).click()
|
|
instance_url = driver.find_element_by_xpath('//h5')
|
|
description = driver.find_element_by_id('modalInstanceInfo-description')
|
|
print ('Instance:')
|
|
print(instance_url.text)
|
|
print ('Description:')
|
|
print(description.text)
|
|
time.sleep(0.5)
|
|
|
|
# closes pop up
|
|
driver.find_element_by_css_selector('.btn.btn-secondary').click()
|
|
time.sleep(0.5)
|
|
|
|
# scroll to just under the video in order to load the comments
|
|
driver.execute_script('window.scrollTo(1, 40);')
|
|
time.sleep(0.5)
|
|
|
|
d+=1
|
|
|
|
# close the browser
|
|
driver.close()
|