-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathposhmarkBot.py
More file actions
71 lines (57 loc) · 2.22 KB
/
Copy pathposhmarkBot.py
File metadata and controls
71 lines (57 loc) · 2.22 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import re
from robobrowser import RoboBrowser
import random
import time
# Browse to Poshmark
browser = RoboBrowser(history=True)
browser.open('https://poshmark.com/login')
# Get username and pw from text file
# First line of text file must be in the following form:
# 'username password'
# the info array will have two entire, the username and pw
# at indices 0 and 1
userInfo = open('userInfo.txt','r')
info = userInfo.read().split(' ')
# fill out the form with necessary inputs
form = browser.get_form(id = 'email-login-form')
form # <RoboForm q=>
form['login_form[username_email]'].value = info[0]
form['login_form[password]'].value = info[1]
browser.submit_form(form)
#Actually do the search
searchList = raw_input('What would you like to search for? Separate your search queries with spaces: ')
sum = 0;
# Initialize the link-holder array and the query array
linksToVisit = []
searchQuery = searchList.split(' ')
# Iterate through all the search values
for searchVal in searchQuery:
browser.open('https://poshmark.com/search?query=' + searchVal + '&type=people')
# Compile list of users to go to
print 'Here are all users you are going to visit from search ' + searchVal + ':'
for link in browser.find_all('a'):
if (str(link.get('href'))[:6] == '/user/' and str(link.get('href'))[-12:] == '/follow_user'):
linksToVisit.append(str(link.get('href')))
print link.get('href')
# Actually visits them. And sleeps a lot too.
if (len(linksToVisit) == 0):
print 'No users were returned'
else:
for url in linksToVisit:
timetosleep = int(random.random() * 10)
print 'sleeping for ' + str(timetosleep) + ' seconds.'
time.sleep(timetosleep)
print 'followed user ' + url
browser.open('https://poshmark.com' + url)
time.sleep(int(random.random() * 2))
browser.back()
# Keep adding to our cummulative amount
sum = sum + len(linksToVisit)
print 'Done! ' + info[0] + ' just followed ' + str(len(linksToVisit)) + ' people.'
# Delete everything in the linksToVisit array
del linksToVisit[:]
print 'Note: You may have already followed some of these people...'
print 'Your total amount of follows is ' + str(sum) + '.'
# Bugs:
# 1. How to scroll down.
# 2. How do you know if the person is already followed.