sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #18355
Re: [Question #228659]: need help with this software, newbie...
Question #228659 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/228659
Mark Weisler posted a new comment:
Below is some code that might help with this question...
# script: URLWatcher
# cycles through some URLs which are initially loaded into a list
# 22 Mai 2013, Mark Wißler
# written for OS X; could be adapted to other OSs.
# preconditions: a) existence of the URL file, b) Safari is running
import sys, string, os # some libraries we are likely to need
aURL=[] #defining an empty list
URLfile = open('/Users/joe/Documents/URLs.txt', 'r') # file containing our URLs of interest
for line in URLfile: # just to demonstrate the existence of the file and entries
print line,
aURL.append(line) # add each line as item in our list
URLfile.close()
print aURL # demonstrates the list still exists and contains items
myLimit = len(aURL)
print myLimit
print aURL[0]
print aURL[1]
print aURL[2]
########### now moving on to the Web browser...
App("Safari").focus() # bring Safari browser into focus
i = 0 # index for our loop
mycontinue = True
while mycontinue:
type("l", KEY_CMD) # Safari key to open location (or reading list?)
type(Key.DELETE) # deletes any string in the URL field
type(aURL[i]+ Key.ENTER) # then the Web page appears
# we could do some other work here like examine the page
i +=1 # increment index to prepare for next URL to see
if i >=myLimit:
i = 0
wait(5)
# result is that this brings up a web page
# next you would likely evaluate the web page, process it, scrape it, save it, u.s.w.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.