-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlickr_Selenium_Python_Group.py
62 lines (46 loc) · 1.91 KB
/
Flickr_Selenium_Python_Group.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#Import libraries
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.firefox.webdriver import FirefoxProfile
import time
#Import list user usernames
pathtoinput='/home/JohnRambo/Flickr_Usernames.csv'
listcontact = open(pathtoinput)
next(listcontact)
#Instantiate a Firefox webbrowser (the profile should be already logged to Flickr)
pathtoprofile='path to profile'
profile = FirefoxProfile(pathtoprofile)
browser = webdriver.Firefox(profile)
#Url group invitation
url="https://www.flickr.com/groups_invite.gne?id=..."
#Loop over your contact list
k=0
for line in listcontact:
#Url group invitation
browser.get(url)
time.sleep(5)
#Extract Flickr ID
attr = line.rstrip('\n\r').split(';') #Split line
id=(attr[0])
#Identification of subject and message xpath
invit = browser.find_element_by_xpath(".//*[@id='group-invite-bo-selecta-field']")
invit.send_keys(id)
time.sleep(5)
#Hover & click & click
el1=browser.find_element_by_xpath(".//*[@id='bs-dropdown-0']/div[1]/div[2]/ul/li[2]/p")
ActionChains(browser).move_to_element(el1).click().perform()
time.sleep(5)
el2=browser.find_element_by_xpath(".//*[@id='bs-dropdown-0']/div[1]/div[2]/ul/li[1]")
ActionChains(browser).move_to_element(el2).click().perform()
time.sleep(5)
#Write message
message = browser.find_element_by_xpath(".//*[@id='group-invite-form']/p[1]/textarea")
message.send_keys("test")
time.sleep(5)
#Send!
browser.find_element_by_xpath(".//*[@id='group-invite-form']/p[2]/input").click()
time.sleep(5)
browser.find_element_by_xpath(".//*[@id='GoodStuff']/form/p[2]/input[1]").click()
k=k+1
print(str(k) + " " + id + " done!")
time.sleep(5)