Skip to content

Instantly share code, notes, and snippets.

@usrlocalben
Created May 8, 2016 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usrlocalben/eb8c7f763e63480a88280acb4657372b to your computer and use it in GitHub Desktop.
Save usrlocalben/eb8c7f763e63480a88280acb4657372b to your computer and use it in GitHub Desktop.
"""
Let's scrape a few profile details from MyCDE (RIP)
For Sydney, Summer 2013 (Found on an old hdd)
Also, "new message."
"""
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
USERNAME = 'user'
PASSWORD = 'pass'
URL_BASE = 'http://www.cartoondollemporium.com'
def main(driver):
# shortcut
find = driver.find_element_by_css_selector
driver.get(URL_BASE + '/')
# already logged in?
#sel = '#login_section_new > ul > li.hello_member.loggedin > h3 > a'
#elem = find(sel)
#elem.text == USERNAME
sel = '#login_custom > ul > li.login_inputs.username_input > input[type="text"]'
find(sel).send_keys(USERNAME)
sel = '#login_custom > ul > li:nth-child(3) > input[type="password"]'
elem = find(sel)
elem.send_keys(PASSWORD)
elem.send_keys(Keys.RETURN)
# proceed to main profile page
sel = '#page > div:nth-child(1) > a'
find(sel).click()
# get new messages, elem.text == u'11\nNew Messages'
sel = '#page > div.col_right.join_cde > div:nth-child(12) > div > ul > li:nth-child(1) > a'
messages = find(sel).text.split('\n')[0]
# get friend requests, elem.text == u'1\nNew Friend Requests'
sel = '#page > div.col_right.join_cde > div:nth-child(12) > div > ul > li:nth-child(2) > a'
friend_requests = find(sel).text.split('\n')[0]
# get profile comments, elem.text == u'1\nNew Profile Comments'
sel = '#page > div.col_right.join_cde > div:nth-child(12) > div > ul > li:nth-child(3) > a'
profile_comments = find(sel).text.split('\n')[0]
# logout
driver.get(URL_BASE + '/cdeprofile/login.html?logout=1')
print 'Number of new...'
print ' messages:', messages
print ' friend requests:', friend_requests
print ' profile comments:', profile_comments
if __name__ == '__main__':
try:
driver = webdriver.Chrome()
main(driver)
finally:
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment