def FormatHtml(f, idx): #results = d.find(id='bodyMainResults') resultDiv = SoupStrainer('div', id='bodyMainResults') res = BeautifulSoup(f, parseOnlyThese=resultDiv) #tables = res.findChildren('table', attrs={'class':'resultRow'}) #tables = res.contents[0] tables = res.findChildren('table', attrs={'cellspacing':'0','cellpadding':'10'}) for tab in tables: a = tab.find('a') link = a['href'] span = a.findChild('span') #print span.contents #article = span.contents[0] article = ' '.join([s.string for s in span.contents if s.string]) iList = tab.findAll('i') journal = iList[0].contents[0] volumn = iList[1].contents[0] pubDate = iList[2].contents[0] pages = iList[3].contents[0] tds = [td for td in tab.contents] item = tds[1].find('td', attrs={'align':'left','width':'95%','colspan':'2'}) author = item.contents[10] #td1 = tds[1] #author = td1.contents[10] ie = PAMIE() ie.navigate(link) ie.linkClick('References') #ie.quit() idx += 1 print "[", idx, "]", "\n\t", link, "\n\t", article, "\n\t", author, "\n\t", journal, "\n\t", volumn, "\n\t", pages, "\n" #print "[", idx, "]", "\n\t", article, "\n\t", journal, "\n\t", volumn, "\n\t", pages, "\n" print "FETCH page, to ", idx return idx
def LoginPageFromIE(): """ login in the web page with username pwd and code """ ie = PAMIE() ie.navigate("https://epoint.pampers.com.cn/index.aspx") # time.sleep(10) # return ie ie.textBoxSet("email", "*****@*****.**") ie.textBoxSet("password", "sc369963SC") # Downloadcode(ie.cookieGet()) # ie.textBoxSet('yzm',GetCode(CodeFilter())) # time.sleep(15) # ie.formSubmit('form1') ie.formSubmit("fmLogin") # ie.imageClick( if ie.textBoxExists("password"): print "fail to login in, please true again" return None # ie.navigate('http://www.bjguahao.gov.cn/comm/kouqiang/ksyy.php?ksid=1040000&hpid=109') # print ie.pageGetText() # ie.javaScriptExecute(SetDocumentMode()) # ie.javaScriptExecute('document.documentMode="7";') # ie.javaScriptExecute('document.write(document.getElementsByTagName("head"))') # ie.javaScriptExecute('document.getElementsByTagName(\'head\')[0].appendChild(\'<meta http-equiv="X-UA-Compatible" content="IE=7">\');') return ie
def test1(self): self.ie = PAMIE() #self.ie = getIE () #self.ie.navigate('http://www.bjguahao.gov.cn/comm/kouqiang/ksyy.php?ksid=1040000&hpid=109') #self.ie.textBoxGet('yy') #self.ie.linkExists('dd') self.ie.navigate('www.baidu.com') self.ie.textBoxSet('wd','Computer')
def LoginDUT(): os.system('taskkill /im IEXPLORE.EXE') sleep(1) ie = PAMIE( ) sleep(0.1) ie.navigate(IP) sleep(0.5) ie.listBoxSelect('username',username) ie.textBoxSet('password',password) ie.buttonClick("OK") sleep(0.5)
class test: def test2(self): import win32com.client self._ie = win32com.client.DispatchEx('InternetExplorer.Application') self._ie.Visible = 1 self._ie.Navigate('www.baidu.com') time.sleep(5) print self._ie.Document.forms[0].getElementsByTagName("wd").length def test1(self): self.ie = PAMIE() #self.ie = getIE () #self.ie.navigate('http://www.bjguahao.gov.cn/comm/kouqiang/ksyy.php?ksid=1040000&hpid=109') #self.ie.textBoxGet('yy') #self.ie.linkExists('dd') self.ie.navigate('www.baidu.com') self.ie.textBoxSet('wd','Computer')
""" #url = 'http://www.sciencedirect.com/science?_ob=ArticleListURL&_method=tag&refSource=search&_st=13&count=739&_chunk=2&PREV_LIST=1&NEXT_LIST=3&view=c&md5=e528e094dcc02c469caa87884e42fb84&_ArticleListID=987492397&sisr_search=&next=next+page&sisrterm=' url = 'http://www.sciencedirect.com/science?_ob=ArticleListURL&_method=list&_ArticleListID=987492397&_st=13&_acct=C000050221&_version=1&_urlVersion=0&_userid=10&md5=07b2ce065d4fbefa373c5267ca144469' counter = 0 #FormatHtml(ie.outerHTML(), counter) if not os.path.exists("urls.txt"): urlFile = open("urls.txt", 'w') urlFile.write(url + "\n") ie = PAMIE() ie.navigate(url) urls = [url] while ie.buttonClick('next'): url = ie.locationURL() print "NEXT page: ", url urlFile.write(url + "\n") urls.append(url) urlFile.close() print "IE operator OVER" else: urlFile = open("urls.txt", 'r') urls = [url for url in urlFile]
encryption='WEP' passphrase='12345678' wirelessmode ='802.11b/g' def click_ok(a): #for click OK thread sleep(5) if a==1: wga=winGuiAuto popDialog= wga.findTopWindow(wantedText='Microsoft Internet Explorer') OKButton = wga.findControl(popDialog, wantedClass='Button',wantedText='OK') wga.clickButton(OKButton) ie = PAMIE( ) wga = winGuiAuto #ie.navigate("http://"+IP+"/admin.cgi?action=basic_settings") ie.navigate("http://"+IP) login = wga.findTopWindow(wantedText="Connect to "+IP) credential=wga.findControl(login,wantedClass='SysCredential') #find by spi user1=wga.findControl(credential,wantedClass='ComboBoxEx32') #combin combo and edit user2=wga.findControl(credential,wantedClass='ComboBox') user3=wga.findControl(credential,wantedClass='Edit') wga.setEditText(user3,username) ''' ## First enter Alt+p win32api.keybd_event(18,0,0,0) win32api.keybd_event(80,0,0,0) win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0)
def LoginPageFromIE(): ''' login in the web page with username pwd and code ''' global USER global PWD ie = PAMIE() ie.navigate("http://epoint.pampers.com.cn/pages/rewards.aspx?r=5979") #print ie.cookieGet() #time.sleep(10) #return ie ie.textBoxSet('email',USER) #account ie.textBoxSet('password', PWD) #pwd #Downloadcode(ie.cookieGet()) #ie.textBoxSet('yzm',GetCode(CodeFilter())) #time.sleep(15) #ie.formSubmit('form1') ie.formSubmit('fmLogin') #ie.navigate("http://epoint.pampers.com.cn/pages/redeem.aspx?p1=149") while ie.textBoxExists('password'): print 'fail to login in, try again' #ie.navigate("http://epoint.pampers.com.cn/pages/rewards.aspx?r=5979") ie.textBoxSet('email',USER) #account ie.textBoxSet('password', PWD) #pwd ie.formSubmit('fmLogin') ie.navigate("http://epoint.pampers.com.cn/pages/redeem.aspx?p1=149") #print ie.cookieGet() # prepare to in ie.javaScriptExecute('javascript:alert("plese input the ASPXAUTH and ASP.net_Session")') #print 'input ASPXAUTH value' global ASPXAUTH ASPXAUTH = raw_input('ASPXAUTH=') #print 'input asp.net_sessionid value' global ASPNET_SESSIONID ASPNET_SESSIONID = raw_input('ASPNET_SESSIONID=') #ie.navigate("http://epoint.pampers.com.cn/pages/rewards_detail.aspx?p1=149") #ie.navigate("http://epoint.pampers.com.cn/pages/redeem.aspx?p1=149") #print ie.pageGetText() #ie.javaScriptExecute(SetDocumentMode()) #ie.javaScriptExecute('document.documentMode="7";') #ie.javaScriptExecute('document.write(document.getElementsByTagName("head"))') return ie
def LoginPage(): ''' login in the web page with username pwd and code ''' ie = PAMIE() ie.navigate("http://www.bjguahao.gov.cn/comm/yyks.php?hpid=109") #time.sleep(10) #return ie ie.textBoxSet('truename','ÍõÈý') ie.textBoxSet('sfzhm', 'Éí·ÝÖ¤ºÅ') Downloadcode(ie.cookieGet()) ie.textBoxSet('yzm',GetCode(CodeFilter())) #time.sleep(15) ie.formSubmit('form1') if ie.textBoxExists('truename'): print 'fail to login in, please true again' return None #ie.navigate('http://www.bjguahao.gov.cn/comm/kouqiang/ksyy.php?ksid=1040000&hpid=109') #print ie.pageGetText() #ie.javaScriptExecute(SetDocumentMode()) #ie.javaScriptExecute('document.documentMode="7";') #ie.javaScriptExecute('document.write(document.getElementsByTagName("head"))') #ie.javaScriptExecute('document.getElementsByTagName(\'head\')[0].appendChild(\'<meta http-equiv="X-UA-Compatible" content="IE=7">\');') return ie
print "FETCH page, to ", idx return idx """ url = 'c:\\python25\web.html' ie = PAMIE() ie.navigate(url) FormatHtml(ie.outerHTML()) """ #url = 'http://www.sciencedirect.com/science?_ob=ArticleListURL&_method=tag&refSource=search&_st=13&count=739&_chunk=2&PREV_LIST=1&NEXT_LIST=3&view=c&md5=e528e094dcc02c469caa87884e42fb84&_ArticleListID=987492397&sisr_search=&next=next+page&sisrterm=' url = 'http://www.sciencedirect.com/science?_ob=ArticleListURL&_method=list&_ArticleListID=988190031&_sort=v&_st=17&view=c&_acct=C000050221&_version=1&_urlVersion=0&_userid=10&md5=b0d9363ae004117965dbf00dd37582dc' ie = PAMIE() ie.navigate(url) counter = 0 FormatHtml(ie.outerHTML(), counter) #urls = [url] while ie.buttonClick('next'): # url = ie.locationURL() # print "NEXT page: ", url # urls.append(url) counter = FormatHtml(ie.outerHTML(), counter) #for url in urls: # print url # req = urllib2.Request(url)
sleep(1) IP='192.168.3.51/index.html' username = '******' password = '******' def click_ok(a): #for click OK thread sleep(5) if a==1: wga=winGuiAuto popDialog= wga.findTopWindow(wantedText='Microsoft Internet Explorer') OKButton = wga.findControl(popDialog, wantedClass='Button',wantedText='OK') wga.clickButton(OKButton) ie = PAMIE( ) wga = winGuiAuto ##set channel def LoginAP(): ie.navigate("http://"+IP) login = wga.findTopWindow(wantedText="Connect to "+IP) credential=wga.findControl(login,wantedClass='SysCredential') #find by spi user1=wga.findControl(credential,wantedClass='ComboBoxEx32') #combin combo and edit user2=wga.findControl(credential,wantedClass='ComboBox') user3=wga.findControl(credential,wantedClass='Edit') wga.setEditText(user3,username) #login OKButton = wga.findControl(login, wantedClass="Button",wantedText="OK") wga.clickButton(OKButton)
from cPAMIE import PAMIE ie = PAMIE() ie.navigate("www.google.com") ie.textBoxSet("q", "python") ie.buttonClick("btnG")
def G54S(config): ie = PAMIE() wga = winGuiAuto mp = cModalPopUp ie.navigate("http://" + IP + "/advance/advance-lan-wireless.htm") login = wga.findTopWindow(wantedText="Connect to " + IP) credential = wga.findControl(login, wantedClass="SysCredential") user1 = wga.findControl(credential, wantedClass="ComboBoxEx32") user2 = wga.findControl(user1, wantedClass="ComboBox") user3 = wga.findControl(user2, wantedClass="Edit") wga.setEditText(user3, username) ## If password is not null,enter password by win32api.keybd_event ## First enter Alt+p win32api.keybd_event(18, 0, 0, 0) win32api.keybd_event(80, 0, 0, 0) win32api.keybd_event(18, 0, win32con.KEYEVENTF_KEYUP, 0) win32api.keybd_event(80, 0, win32con.KEYEVENTF_KEYUP, 0) ##Then enter password """win32api.keybd_event(82,0,0,0) win32api.keybd_event(82,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(79,0,0,0) win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(79,0,0,0) win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(84,0,0,0) win32api.keybd_event(84,0,win32con.KEYEVENTF_KEYUP,0) time.sleep(10)""" OKButton = wga.findControl(login, wantedClass="Button", wantedText="OK") wga.clickButton(OKButton) ie.navigate("http://" + IP + "/advance/ad-lan-wireless_g.htm") ie.radioButtonSet("wl_radio", "1", checked=True) if config["wirelessmode"] == "802.11b only": wirelessmode = "11b-Only" elif config["wirelessmode"] == "802.11g only": wirelessmode = "11g-Only" elif config["wirelessmode"] == "802.11b/g": wirelessmode = "Mixed" ie.listBoxSelect("wl_gmode", wirelessmode) SSID = config["SSID"] ie.textBoxSet("wl_ssid_input", SSID) if config["autochannel"] == "Disable": ie.checkBoxSet("wl_channel_auto", 0) else: ie.checkBoxSet("wl_channel_auto", 1) channel = config["channel"] ie.listBoxSelect("wl_channel", "Channel " + channel) ie.buttonClick("Apply") time.sleep(10) ie.navigate("http://" + IP + "/advance/ad-lan-wireless_sec_g.htm") ie.radioButtonSet("wl_closed", "0", checked=True) encryption = config["encryption"] if encryption == "None": ie.radioButtonSet("wl_wep", "off", checked=True) elif encryption == "WEP": ie.radioButtonSet("wl_wep", "restricted", checked=True) keyindex = config["keyindex"] keytype = config["keytype"] wepkey = config["wepkey"] ie.radioButtonSet("wl_key", keyindex, checked=True) ie.listBoxSelect("wep_ascii_select" + keyindex, keytype) ie.textBoxSet("wl_key" + keyindex, wepkey) elif encryption == "TKIP": ie.radioButtonSet("wl_wep", "tkip", checked=True) ie.textBoxSet("wl_wpa_psk", config["passphrase"]) elif encryption == "AES": ie.radioButtonSet("wl_wep", "aes", checked=True) ie.textBoxSet("wl_wpa_psk", config["passphrase"]) ie.buttonClick("Apply") time.sleep(10)
def Dlink_DWL_8500AP(config): ie = PAMIE() wga = winGuiAuto # ie.navigate("http://"+IP+"/admin.cgi?action=basic_settings") ie.navigate("http://" + IP) login = wga.findTopWindow(wantedText="Connect to " + IP) credential = wga.findControl(login, wantedClass="SysCredential") # find by spi user1 = wga.findControl(credential, wantedClass="ComboBoxEx32") # combin combo and edit user2 = wga.findControl(credential, wantedClass="ComboBox") user3 = wga.findControl(credential, wantedClass="Edit") wga.setEditText(user3, username) """ ## First enter Alt+p win32api.keybd_event(18,0,0,0) win32api.keybd_event(80,0,0,0) win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(80,0,win32con.KEYEVENTF_KEYUP,0) ##Then enter password admin win32api.keybd_event(97,0,0,0) #a win32api.keybd_event(97,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(100,0,0,0) #d win32api.keybd_event(100,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(109,0,0,0)#m win32api.keybd_event(109,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(105,0,0,0)#i win32api.keybd_event(105,0,win32con.KEYEVENTF_KEYUP,0) win32api.keybd_event(110,0,0,0)#n win32api.keybd_event(110,0,win32con.KEYEVENTF_KEYUP,0) sleep(10) """ # user4=wga.findControl(credential,wantedClass='Edit') # wga.setEditText(user4,password) # click login buttion OKButton = wga.findControl(login, wantedClass="Button", wantedText="OK") wga.clickButton(OKButton) ##set channel channel = config["channel"] ie.listBoxSelect("radio.wlan1.channel", channel) # select 11bg mode ie.navigate("http://" + IP + "/admin.cgi?action=radio") ie.listBoxSelect("radioInterface", "2") ie.listBoxSelect("radio.wlan0.mode", "IEEE 802.11g") sleep(1) if config["wirelessmode"] == "802.11b only": ie.checkBoxSet("supported-rate.wlan1.0", 0) ie.checkBoxSet("supported-rate.wlan1.1", 0) ie.checkBoxSet("supported-rate.wlan1.2", 0) ie.checkBoxSet("supported-rate.wlan1.3", 0) ie.checkBoxSet("supported-rate.wlan1.4", 0) ie.checkBoxSet("supported-rate.wlan1.5", 0) ie.checkBoxSet("supported-rate.wlan1.6", 1) ie.checkBoxSet("supported-rate.wlan1.7", 0) ie.checkBoxSet("supported-rate.wlan1.8", 0) ie.checkBoxSet("supported-rate.wlan1.9", 1) ie.checkBoxSet("supported-rate.wlan1.10", 1) ie.checkBoxSet("supported-rate.wlan1.11", 1) ie.checkBoxSet("basic-rate.wlan1.0", 0) ie.checkBoxSet("basic-rate.wlan1.1", 0) ie.checkBoxSet("basic-rate.wlan1.2", 0) ie.checkBoxSet("basic-rate.wlan1.3", 0) ie.checkBoxSet("basic-rate.wlan1.4", 0) ie.checkBoxSet("basic-rate.wlan1.5", 0) ie.checkBoxSet("basic-rate.wlan1.6", 0) ie.checkBoxSet("basic-rate.wlan1.7", 0) ie.checkBoxSet("basic-rate.wlan1.8", 0) ie.checkBoxSet("basic-rate.wlan1.9", 0) ie.checkBoxSet("basic-rate.wlan1.10", 1) ie.checkBoxSet("basic-rate.wlan1.11", 1) elif config["wirelessmode"] == "802.11g only": ie.checkBoxSet("supported-rate.wlan1.0", 1) ie.checkBoxSet("supported-rate.wlan1.1", 1) ie.checkBoxSet("supported-rate.wlan1.2", 1) ie.checkBoxSet("supported-rate.wlan1.3", 1) ie.checkBoxSet("supported-rate.wlan1.4", 1) ie.checkBoxSet("supported-rate.wlan1.5", 1) ie.checkBoxSet("supported-rate.wlan1.6", 0) ie.checkBoxSet("supported-rate.wlan1.7", 1) ie.checkBoxSet("supported-rate.wlan1.8", 1) ie.checkBoxSet("supported-rate.wlan1.9", 0) ie.checkBoxSet("supported-rate.wlan1.10", 0) ie.checkBoxSet("supported-rate.wlan1.11", 0) ie.checkBoxSet("basic-rate.wlan1.0", 0) ie.checkBoxSet("basic-rate.wlan1.1", 0) ie.checkBoxSet("basic-rate.wlan1.2", 0) ie.checkBoxSet("basic-rate.wlan1.3", 1) ie.checkBoxSet("basic-rate.wlan1.4", 0) ie.checkBoxSet("basic-rate.wlan1.5", 1) ie.checkBoxSet("basic-rate.wlan1.6", 0) ie.checkBoxSet("basic-rate.wlan1.7", 0) ie.checkBoxSet("basic-rate.wlan1.8", 1) ie.checkBoxSet("basic-rate.wlan1.9", 0) ie.checkBoxSet("basic-rate.wlan1.10", 0) ie.checkBoxSet("basic-rate.wlan1.11", 0) elif config["wirelessmode"] == "802.11b/g": ie.checkBoxSet("supported-rate.wlan1.0", 1) ie.checkBoxSet("supported-rate.wlan1.1", 1) ie.checkBoxSet("supported-rate.wlan1.2", 1) ie.checkBoxSet("supported-rate.wlan1.3", 1) ie.checkBoxSet("supported-rate.wlan1.4", 1) ie.checkBoxSet("supported-rate.wlan1.5", 1) ie.checkBoxSet("supported-rate.wlan1.6", 1) ie.checkBoxSet("supported-rate.wlan1.7", 1) ie.checkBoxSet("supported-rate.wlan1.8", 1) ie.checkBoxSet("supported-rate.wlan1.9", 1) ie.checkBoxSet("supported-rate.wlan1.10", 1) ie.checkBoxSet("supported-rate.wlan1.11", 1) ie.checkBoxSet("basic-rate.wlan1.0", 0) ie.checkBoxSet("basic-rate.wlan1.1", 0) ie.checkBoxSet("basic-rate.wlan1.2", 0) ie.checkBoxSet("basic-rate.wlan1.3", 0) ie.checkBoxSet("basic-rate.wlan1.4", 0) ie.checkBoxSet("basic-rate.wlan1.5", 0) ie.checkBoxSet("basic-rate.wlan1.6", 1) ie.checkBoxSet("basic-rate.wlan1.7", 0) ie.checkBoxSet("basic-rate.wlan1.8", 0) ie.checkBoxSet("basic-rate.wlan1.9", 1) ie.checkBoxSet("basic-rate.wlan1.10", 1) ie.checkBoxSet("basic-rate.wlan1.11", 1) thread.start_new_thread(click_ok, (1,)) ie.buttonClick("Update")