def start(self, capabilities, port='9000', driver_name='chrome', host='http://127.0.0.1'): ''' Starts the webdriver and creates the session :param capabilities: The capabilities to run the session :param port: the port where the web driver will run :param driver_name: chrome (more to come soon...) :param host: by default 127.0.0.1 if you want to run this from another site put your host. :return: X ''' self.webdriver_exec.launch_driver(port, driver_name) self.host = host + ':' + port + '/' response = requests.request( 'POST', self.host + 'session', data=json.dumps(capabilities).encode('utf8')) self.session_id = json.loads(response.text)[ 'sessionId'] # Todo: see if session_id variable is necesary self.request_url = self.host + 'session/' + self.session_id self.interactions = Interactions(self.host, self.session_id) self.elements = Elements(self.host, self.session_id) self.browser = Browser(self.request_url)
def logger_wrap(*args, **kwargs): try: f(*args, **kwargs) except: debug("Unexpected error:", sys.exc_info()[0]) Browser.get().save_screenshot("error_" + str(time.time()) + ".png") raise
def __init__(self): if Env.isWindows(): chrome_path = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" elif Env.isMac(): chrome_path = r"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" else: raise Exception("Unsupported OS") Browser.__init__(self, "google chrome", chrome_path) self.name = "google chrome" self.path = chrome_path
def test_separate_playwright_port(): browser = Browser.Browser() browser.new_context() browser2 = Browser.Browser() browser.new_context() assert browser.playwright.port != browser2.playwright.port assert browser2.get_browser_catalog() != browser.get_browser_catalog() browser.close_browser("ALL") browser2.close_browser("ALL")
def test_shared_playwright_port(): browser = Browser.Browser() browser.new_context() assert browser.playwright.port port: str = browser.playwright.port browser2 = Browser.Browser(playwright_process_port=int(port)) # assert browser.playwright.port == browser2.playwright.port browser2.new_context() assert browser.playwright.port == browser2.playwright.port assert browser2.get_browser_catalog() == browser.get_browser_catalog() browser.close_browser("ALL") browser2.close_browser("ALL")
def browser(monkeypatch): import Browser browser = Browser.Browser() yield browser browser.close_browser("ALL") browser._close
def __init__(self, design, closefun, close=0): self.Ok = None self.Apply = None self.mDesign = design self.mHistoryForm = None if self.mDesign.isBlockObject(): self.mHistory = ["topblock %s" % oaTracerUtl22.getCellviewFullname(self.mDesign)] if self.mDesign.isModObject(): if self.mDesign == self.mDesign.getTopModule(): self.mHistory = ["topmod %s" % oaTracerUtl22.getCellviewFullname(self.mDesign)] else: self.mHistory = ["designmodule %s %s" % oaTracerUtl22.getModuleFullname(self.mDesign)] if self.mDesign.isOccObject(): self.mHistory = ["topocc %s" % oaTracerUtl22.getCellviewFullname(self.mDesign)] self.mTop = None self.mCloseFun = closefun self.mClose = close self.mNetUtil = oaTracerNetutl22.cTracerNetUtility(self.mDesign, self.PickNet) self.mTermUtil = oaTracerTermutl22.cTracerTermUtility(self.mDesign, self.PickTerm) self.mInstUtil = oaTracerInstutl22.cTracerInstUtility(self.mDesign, self.PickInst) self.mBrowser = Browser.cBrowser(self.mDesign, BrowserOA22.cOpenAccessBrowserHints(), 1) self.mCvUtil = oaTracerCvutl22.cTracerDesignUtility("Pick Library Cell View", self.PickCv) self.mHistoryForm = cHistoryLister(self) # Empty cmd.log file self.first_cmd = 1 filename = "oaTracerCmd.log" if filename: try: fp = open(filename, "w") fp.close() except: pass
def search(query, **options): options.update({'v': '1.0', 'key': APIKEY, 'q': '"%s"' % (query)}) result = simplejson.JSONDecoder().decode( Browser.fetch( 'http://ajax.googleapis.com/ajax/services/search/blogs?' + urlencode(options))) return result['responseData']
def BrowserInit(self): self.browser = Scroller(self.group, Browser(self.level), self.image, 30, BLACK, 36, 15, 400, 300) self.browser.level = self.browser.browser.level self.browser.rect = (300, 350) if self.isSelected: self.SetSelected()
def main(): parser = optparse.OptionParser() parser.add_option("--use-tray-icon", dest="tray_icon", action="store_true", default=False) parser.add_option("--no-tray-icon", dest="tray_icon", action="store_false") parser.add_option("--hide-main-window", action="store_true", default=False) parser.add_option("-m", "--map", action="store", type="string", dest="filename", help="Open a map from a given filename (from internal database)") parser.add_option("-o", "--open", action="store", type="string", dest="filepath", help="Open a map from a given filename (including path)") (options, args) = parser.parse_args() if not options.tray_icon: options.hide_main_window=False MapBrowser = Browser.Browser ( start_hidden = options.hide_main_window, tray_icon = options.tray_icon ) if options.filename != None: MapBrowser.open_map_filename (utils.get_save_dir() + options.filename) elif options.filepath != None: MapBrowser.open_map_filename (options.filepath) try: gtk.main() except: print "Exception caught while running. Dying a death." sys.exit(1)
def run_with_rfbrowser(rh, sheet): print("Running RPA Challenge with RFBrowser (RobotFramework Playwright)") browser = Browser.Browser() browser.new_context() browser.set_browser_timeout("30s") browser.new_page(rpachallenge_site) browser.click('"Start"') for row in sheet: browser.fill_text('//input[@ng-reflect-name="labelFirstName"]', row["First Name"]) browser.fill_text('//input[@ng-reflect-name="labelLastName"]', row["Last Name"]) browser.fill_text('//input[@ng-reflect-name="labelCompanyName"]', row["Company Name"]) browser.fill_text('//input[@ng-reflect-name="labelRole"]', row["Role in Company"]) browser.fill_text('//input[@ng-reflect-name="labelAddress"]', row["Address"]) browser.fill_text('//input[@ng-reflect-name="labelEmail"]', row["Email"]) browser.fill_text('//input[@ng-reflect-name="labelPhone"]', str(row["Phone Number"])) browser.click('input[type="submit"]') result = browser.get_text(".message2") rh.check_for_new_record(browser, result) browser.close_browser()
def browser(monkeypatch): import Browser browser = Browser.Browser() yield browser browser.close_all_browsers() browser._close
def test_playwright_double_close(): import Browser browser = Browser.Browser() browser.new_browser() browser.playwright.close() browser.playwright.close()
def publicLoginBySellerCenter(self): br = Browser.Browser().init_browserByCustomerCenter() time.sleep(3) br.find_element_by_id('userName').send_keys('*****@*****.**') br.find_element_by_id('passWord').send_keys('wwg123456') br.find_element_by_id("checkCode").send_keys('12345') br.find_element_by_id('submit-btn').click() return br
def search(query, **options): options.update({ 'v': '1.0', 'key': APIKEY, 'q': '"%s"' % (query) }) result = simplejson.JSONDecoder().decode(Browser.fetch('http://ajax.googleapis.com/ajax/services/search/blogs?' + urlencode(options))) return result['responseData']
def run_crawler(self, url): html = self.get_page(url) soup = Browser.get_soup(html=html) self.get_data(soup) if len(self.comment) == 0: return 0, 0, 0 pos, total = ML().get_score(self.comment) avg_star = np.sum(np.array(self.star)) / total return pos, total, avg_star
def words_page(character, page): params = {} params['character'] = character params['page'] = page return etree.parse( StringIO( Browser.fetch('http://www.urbandictionary.com/browse.php?' + urlencode(params))), parser)
def test_forcefully_different_peer_id(): browser = Browser.Browser() browser.new_page("https://youtube.com") assert browser.playwright.port port: str = browser.playwright.port browser2 = Browser.Browser(playwright_process_port=int(port)) assert browser.playwright.port == browser2.playwright.port assert browser.get_browser_catalog() == browser2.get_browser_catalog() old_id = browser2.set_peer_id("different") assert browser2.set_peer_id("different") == "different" assert old_id != "different" browser2.new_page("https://google.com") assert browser.get_browser_catalog() != browser2.get_browser_catalog() browser.close_browser("ALL") browser2.close_browser("ALL")
def lemma_page_expanded(lemma, page): """Given a lemma and page it returns the DOM for the page-th page of definitions for lemma""" q = {} q['page'] = page q['term'] = lemma result = Browser.fetch('http://www.urbandictionary.com/define.php?' + urlencode(q)) # Transform all "br"s into newlines result = re.compile("\<br ?/?\>").sub("\n", result) return etree.parse(StringIO(result), parser)
def bl(self): if self._bl is None: self.bl = Browser.Browser(timeout='30s', auto_closing_level='SUITE', enable_presenter_mode=True) self._bl.new_browser(browser=SupportedBrowsers.chromium, headless=False) self._bl.new_context() self._bl.new_page() return self._bl
def test_playwright_exit_handler(atexit_register): import Browser browser = Browser.Browser() try: atexit_register.assert_not_called() browser.new_browser() atexit_register.assert_called_with(browser.playwright.close) finally: browser.playwright.close()
def __init__(self, film_list): self.film_list = film_list self.LinkImage = "" # Lấy link film cho vào hàm download_image (Không liên quan đến data frame) self.NAMEFILM = "" # Lấy tên file cho vào hàm save_image (Không liên quan đến data frame) self.data_frame = pd.DataFrame(columns=[ 'LinkFilm', 'NameFilm', 'Star', 'Date', 'Description', 'TotalComment', 'PositiveComment', 'AVGStar' ]) self.browser = Browser.get_driver() self.output_image = setting.DIR_PATH_DATA + "/image"
def __init__(self, master): self.master = master Tk.Frame.__init__(self, master) self.server_list = Browser.LoadServers() self.server_listbox = Tk.Listbox(self) self.selectButton = Tk.Button(self, text='select', command=self.select) self.server_listbox.pack(expand=1, fill=Tk.BOTH) self.selectButton.pack(side=Tk.BOTTOM, expand=0, fill=Tk.X) self.populate()
def test_forcibly_same_peer_id(): browser = Browser.Browser() browser.set_peer_id("new_id") browser.new_page("https://youtube.com") catalog_with_only_youtube = browser.get_browser_catalog() assert browser.playwright.port port: str = browser.playwright.port browser2 = Browser.Browser(playwright_process_port=int(port)) browser2.set_peer_id("new_id") # assert browser.playwright.port == browser2.playwright.port browser2.new_page("https://google.com") assert browser.playwright.port == browser2.playwright.port assert browser.get_browser_catalog() == browser2.get_browser_catalog() assert browser.get_browser_catalog() != catalog_with_only_youtube browser.close_browser("ALL") browser2.close_browser("ALL")
def select(self): selection = self.server_listbox.get(self.server_listbox.curselection()) msg = Tk.Label(self, text="".join(("Loading ", selection))) msg.pack(expand=1, fill=Tk.BOTH) self.server_listbox.pack_forget() self.selectButton.pack_forget() self.update() browser = Browser.Browser(self, self.server_list[selection]) msg.pack_forget() browser.pack(expand=1, fill=Tk.BOTH)
def words_to_number(words): try: browser = Browser.Browser() response = browser.open('http://www.wolframalpha.com/input/?i=' + urllib.quote_plus(words)).read() return re.search(r"javascript:showmathpop\('(\d+)'\)", response).group(1) except Exception as ex: return -1
def button_2_release(self, event): here = self.__viewer.text.index(At(event.x, event.y)) if here != self.__here: return viewer = self.__viewer url = viewer.context.get_baseurl(self.__url) viewer.master.update_idletasks() import Browser app = viewer.context.app b = Browser.Browser(app.root, app) b.context.load(url) viewer.remove_temp_tag(histify=1)
def publicLoginBySeller(self): br = Browser.Browser().init_browser() br.find_element_by_link_text(u"请登录").click() time.sleep(2) br.find_element_by_id('userName').send_keys('*****@*****.**') time.sleep(2) br.find_element_by_id('password').send_keys('wwg123456') br.find_element_by_id('imgLogin').click() time.sleep(2) br.switch_to.alert.accept() time.sleep(5) return br
def help_cmd(self, event=None): """Dispatch browser on self.help_url.""" if not self.app.browsers: print "No browser left to dislay help." return browser = self.helpbrowser if not browser or not browser.valid(): import Browser browser = Browser.Browser(self.app.root, self.app) self.helpbrowser = browser helproot = self.app.prefs.Get('landmarks', 'grail-help-root') browser.context.load(urlparse.urljoin(helproot, self.HELP_URL)) browser.root.tkraise()
def main(args): try: arguments, values = getopt.getopt(argumentList, unixOptions, gnuOptions) except getopt.error as err: # output error, and return with an error code print(str(err).capitalize()) sys.exit(2) for curArg, curValue in arguments: if curArg in ('-h', '--help'): print('-h --help Displays help commands\n'\ '-g Takes a status screenshot of the graph from DownDetector\n'\ ' (usage: -s youtube) or if a product/service has more than two words add quotes\n'\ ' (e.g -s "fox-news")\n'\ '-m Same as -s but as the map') elif curArg in ('-s'): brwsr = Browser.BrowserHandle() print(curValue) status = brwsr.brwsr(curValue, 'chart-row') if status != 404: check_output('start filename.png', shell=True) else: print('Page might not exist. Check the spelling of the product/service.\n'\ 'If the product/service has more than than one word (for example-\n'\ 'call of duty,) with quotes type it like so "call of duty"') elif curArg in ('-m'): brwsr = Browser.BrowserHandle() print('mapping it') status = brwsr.brwsr(curValue, 'map') if status != 404: check_output('start filename.png', shell=True) else: print('Page might not exist. Check the spelling of the product/service.\n' \ 'If the product/service has more than than one word (for example-\n' \ 'call of duty,) with quotes type it like so "call of duty"')
def get_data(self, list_url): #开始访问获取http响应 try: Browsers = Browser.Browser() mongodb = mongodb_con.mongodb_con() for url in list_url: data = Browsers.callback_spider_data(url) if data != False: mongodb.into_target(self.config_main.callback_domain(), data) self.data.extend(Browsers.callback_data()) finally: Browsers.close() mongodb.close()
def statistics_for_lemma(lemma): """Given a lemma it returns ???""" result = {} def_ids = [] pages = lemma_pages(lemma) for i in xrange(1, pages + 1): doc = lemma_page(lemma, i) # Get all the ids for the definitions def_ids_in_page = [ x.replace('entry_', '') for x in doc.xpath( "//div[@id='list_items']/div[@class='list_item']/div[@class='entry']/attribute::id" ) ] def_ids += def_ids_in_page # After we are done with fetching all the definition ids, fetch the votes (altogether) votes_regex = re.compile('Uncacheable.thumbs_update\(\{' + '((' + '"current_vote":""|' + '"thumbs_up":(?P<up>[0-9]*)|' + '"id":(?P<id>[0-9]*)|' + '"thumbs_down":(?P<down>[0-9]*)' + '),?)*' + '\}\);') votes = Browser.fetch( 'http://www.urbandictionary.com/uncacheable.php?ids=' + ','.join(def_ids)) total_votes_up = 0 total_votes_down = 0 for x in votes_regex.finditer(votes): def_id = x.group('id') votes_up = int(x.group('up')) votes_down = int(x.group('down')) total_votes_up += votes_up total_votes_down += votes_down result['count_defs'] = len(def_ids) result['total_votes_up'] = total_votes_up result['total_votes_down'] = total_votes_down result['total_votes'] = total_votes_up + total_votes_down return result
def statistics_for_lemma(lemma): """Given a lemma it returns ???""" result = {} def_ids = [] pages = lemma_pages(lemma) for i in xrange(1, pages + 1): doc = lemma_page(lemma, i) # Get all the ids for the definitions def_ids_in_page = [ x.replace('entry_', '') for x in doc.xpath("//div[@id='list_items']/div[@class='list_item']/div[@class='entry']/attribute::id") ] def_ids += def_ids_in_page # After we are done with fetching all the definition ids, fetch the votes (altogether) votes_regex = re.compile('Uncacheable.thumbs_update\(\{' + '((' + '"current_vote":""|' + '"thumbs_up":(?P<up>[0-9]*)|' + '"id":(?P<id>[0-9]*)|' + '"thumbs_down":(?P<down>[0-9]*)' + '),?)*' + '\}\);') votes = Browser.fetch('http://www.urbandictionary.com/uncacheable.php?ids=' + ','.join(def_ids)) total_votes_up = 0 total_votes_down = 0 for x in votes_regex.finditer(votes): def_id = x.group('id') votes_up = int(x.group('up')) votes_down = int(x.group('down')) total_votes_up += votes_up total_votes_down += votes_down result['count_defs'] = len(def_ids) result['total_votes_up'] = total_votes_up result['total_votes_down'] = total_votes_down result['total_votes'] = total_votes_up + total_votes_down return result
def init(details): global people d=details.copy() del d["Keywords"] del d["Gender"] print "[INFO] Starting Twitter Engine" source=b.open('https://twitter.com/search?q='+" ".join(d.values())+'&src=typd&mode=users') print "[INFO]Starting Parsing" from bs4 import BeautifulSoup as bs #source=open("googleDummy","r").read() div=bs(source).find("ol",{"class":"stream-items js-navigable-stream"}) divs=div.findAll("li") print "[INFO] Found "+str(len(divs))+" profiles" i=1 for d in divs: print "[INFO] Grabbing "+str(i)+" profile" temp={} temp["name"]=d.find("strong",{"class":"fullname js-action-profile-name"}).text temp["info"]=d.find("p",{"class":"bio "}).text temp["twitter_name"]=str(filter(lambda x:ord(x)>31 and ord(x)<128,d.find("span",{"class":"username js-action-profile-name"}).text)) temp["image"]=d.find("img")["src"] temp["profile_url"]="https://twitter.com/"+temp["twitter_name"].replace("@","") i+=1 people.append(temp)
def start_processing(self): while True: self.db = DBWraper(self.w1) cred_list = self.db.get_cred_list_crawler_one() if not cred_list: print "Cred List Not Found." break for each_cred in cred_list: last_unread_cat_ = self.db.read_last_unread_category(each_cred[0]) if not last_unread_cat_: print 'No unread category found!' continue browser = Browser() #uname = each_cred[1] #password = each_cred[2] b = browser.OpenURL(login_url) if not b: print 'Login URL open failed.' continue ##Do Login uNameElement = browser.FindElementById('UserNameTextbox') if not uNameElement: print 'Email element not found!' continue browser.TypeInto(each_cred[1],uNameElement) passElement = browser.FindElementById('UserPasswordTextbox') if not passElement: print 'Password element not found!' continue browser.TypeInto(each_cred[2],passElement) signInButton = browser.FindElementById('ctl00_ContentPlaceHolderMainContent_LoginControl_LoginButton') if not signInButton: print 'Sign In button not found!' continue browser.ClickElement(signInButton) uNameElement = browser.FindElementByName('ctl00$ContentPlaceHolderMainContent$LoginControl$UserNameTextbox') if uNameElement: print 'May be the account is blocked!' self.db.mark_login_as_blocked(each_cred[0]) continue print "Logged In..." ###Login is done. page = browser.GetPage() soup = BeautifulSoup(page) category_urls = soup.find_all('a',{'class':'serviceCategoryUrl'}) url_to_go = None for each_url in category_urls: cat_name = each_url.text.strip() cat_url = each_url['href'] url_to_go = cat_url break if not url_to_go: login_cred_record = (each_cred[0],each_cred[1],each_cred[2],0,1) self.db.update_login_cred(login_cred_record) continue for i in range(3): ###Read the last non-visited category for this login. category_name = None last_unread_cat = self.db.read_last_unread_category(each_cred[0]) if not last_unread_cat: login_cred_record = (each_cred[0],each_cred[1],each_cred[2],0,0,1) self.db.update_login_cred_basic_info_fetched(login_cred_record) browser.Close() continue category_name = last_unread_cat[2] b = browser.OpenURL(url_to_go) if not b: print 'Category URL open failed.' print 'Url: ' print url_to_go continue search_box = browser.FindElementById('searchBox') if not search_box: print 'Searchbox Element Not Found!' continue browser.ClearText(search_box) browser.TypeInto(category_name,search_box) search_submit_button = browser.FindElementById('searchSubmit') browser.ClickElement(search_submit_button) ##Now collect page untill page is over. result = [] page_index = 0 while True: page_index += 1 page_url = browser.GetPageURL() page = browser.GetPage() basic_info_list,next_button_available,total_records_count = Parser.parse_basic_info(page) page_count = Parser.parse_page_count_total(page) print 'Total Records Count %s' % str(total_records_count) address_tuple = Parser2.parse_address_from_searchbar(page) #basicinfolist = basic_info_list t = [] for i in basic_info_list: i['s_primaryaddress'] = address_tuple[0] i['s_primarylocation'] = address_tuple[1] i['s_address'] = address_tuple[2] i['s_city'] = address_tuple[3] i['s_state'] = address_tuple[4] i['s_zip'] = address_tuple[5] i['l_address'] = address_tuple[6] i['l_city'] = address_tuple[7] i['l_state'] = address_tuple[8] i['l_zip'] = address_tuple[9] i['link'] = page_url t += [i] basic_info_list = t result += basic_info_list if total_records_count < 20: break browser.scroll_to_pager_link() time.sleep(3) elem = browser.FindElementByClassName('.next') if elem: browser.ClickElement(elem) time.sleep(3) import math if math.ceil(float(page_count)/20 <= page_index): break temp_results = [] for each in result: if not each in temp_results: temp_results += [each] result = temp_results filtered_results = [] for each_basic_info in result: nor = 0 try: nor = int(each_basic_info['num_of_reviews']) except Exception,msg: pass if each_basic_info['buy_itnow'] == 'Yes' or each_basic_info['coupon'] == 'Yes': filtered_results += [each_basic_info] else: if each_basic_info['rating'] == 'A': if nor >= 4 and each_basic_info['link']: filtered_results += [each_basic_info] elif each_basic_info['rating'] == 'B': if nor >= 15 and each_basic_info['link']: filtered_results += [each_basic_info] self.db.save_basic_info(filtered_results,each_cred[0],category_name) self.db.mark_category_read(last_unread_cat[0]) sleep_time_1min = randint(10,25) print 'Sleeping %s minutes' % str(sleep_time_1min/60) time.sleep(sleep_time_1min) print 'Sleeping done.' browser.Close() sleep_time_1min = randint(100,200) print 'Sleeping %s minutes' % str(sleep_time_1min/60) time.sleep(sleep_time_1min) print 'Sleeping done.' sleep_time_10mins = randint(100,200) print 'Sleeping %s minutes' % str(sleep_time_10mins/60) time.sleep(sleep_time_10mins) print 'Sleeping done.' self.w1 = not self.w1 self.db.close()
def init(details): x=raw_input("is your facebook logged in? y/n") if x=="n": global people d=details.copy() del d["Keywords"] del d["Gender"] print "[INFO] Starting Fb Engine" source=b.open('https://www.facebook.com/search.php?q='+" ".join(d.values())) print "[INFO]Starting Parsing" from bs4 import BeautifulSoup as bs divs=bs(source).find("div",{"id":"pagelet_search_results"}).findAll("div",{"class":"clearfix"}) print "[INFO] Found "+str(len(divs))+" profiles" i=1 for d in divs: print "[INFO] Grabbing "+str(i)+" profile" try: temp={} #print d temp["name"]=d.find("div",{"class":"instant_search_title"}).text #temp["Institution"]=d.find("div",{"class":"q0a axa"}).text #temp["User_ids"]=d.find("a",{"class":"R9a Kra LXa AIa ob"})["href"].replace("/","") temp["images"]=d.find("img",{"class":"img"})["src"] temp["profile_url"]=d.find("div",{"class":"instant_search_title"}).find("a")["href"] temp["friends"]=[] temp["tags"]=[] #Trying to grab all basic info try: s=bs(str(d).replace("</"," </")).findAll("span",{"class":"fbProfileBylineFragment"}) for ss in s: temp["tags"]=temp["tags"]+ss.text.lower().split() temp["tags"]=list(set([str(x) for x in list(set(temp["tags"]))])) print "[INFO] got some basic info for "+str(i) except: print "[INFO] no basic info for "+str(i) except: pass i+=1 people.append(temp) elif x=="y": global people d=details.copy() del d["Keywords"] del d["Gender"] print "[INFO] Starting Fb Engine" from selenium import webdriver print "[INFO] Runnning Ghost !" print "[INFO] Ghost started !" driver = webdriver.Chrome("/home/tilak/chromedriver") driver.get("https://www.facebook.com/TilakPatidarBhopal") inputEmail = driver.find_element_by_id("email") inputEmail.send_keys("*****@*****.**") inputPass = driver.find_element_by_id("pass") inputPass.send_keys("hacker524891") inputPass.submit() inputQuery=driver.find_element_by_name("q") driver.get('https://www.facebook.com/search/str/'+" ".join(d.values())+'/keywords_users') print "[INFO]Starting Parsing" from bs4 import BeautifulSoup as bs source=driver.page_source divs=bs(source).findAll("div",{"class":"_3u1 _gli _ajr"}) print "[INFO] Found "+str(len(divs))+" profiles" i=1 for d in divs: print "[INFO] Grabbing "+str(i)+" profile" try: k=d.find("div",{"class":"_gll"}) temp={} #print d temp["name"]=k.find("div",{"class":"_5d-5"}).text #temp["Institution"]=d.find("div",{"class":"q0a axa"}).text #temp["User_ids"]=d.find("a",{"class":"R9a Kra LXa AIa ob"})["href"].replace("/","") temp["images"]=d.find("img",{"class":"img"})["src"] temp["profile_url"]=k.find("a")["href"] if "profile.php" in temp["profile_url"]: print "[INFO] Cannot scrap the profile" continue print "herrree",temp["profile_url"] temp["friends"]=[] temp["tags"]=d.find("div",{"class":"_glo"}).text.split(" ") #Trying to grab all basic info except Exception as e: print e try: if "?" in temp["profile_url"]: temp["profile_url"]=temp["profile_url"].split("?")[0] driver.get(temp["profile_url"]+"/friends") else: driver.get(temp["profile_url"]+"/friends") li=bs(driver.page_source).findAll("li",{"class":"_698"}) for l in li: t={} t["profile"]=str(l.find("div",{"class":"fsl fwb fcb"}).find("a")["href"]) t["name"]=str(l.find("div",{"class":"fsl fwb fcb"}).find("a").text).split("?")[0] temp["friends"].append(t) except: pass try: misc={} if "?" in temp["profile_url"]: temp["profile_url"]=temp["profile_url"].split("?")[0] driver.get(temp["profile_url"]+"/about?section=contact-info") else: driver.get(temp["profile_url"]+"/about?section=contact-info") li=bs(driver.page_source).findAll("li",{"class":"_3pw9 _2pi4 _2ge8"}) for l in li: t=l.findAll("span") da=t[1].text try: if da.lower().index("ask")>=0: if not temp.has_key("misc"): temp["misc"]={} except Exception as e: misc[t[0].text.lower().strip()]=da temp["misc"]=misc except Exception as e: print e temp["misc"]={} i+=1 people.append(temp)
def get_help(self, button): Browser.open("file:///opt/Nqa-Audiobook-player/Help/nqaap.html")
def init(details): global people d=details.copy() del d["Keywords"] del d["Gender"] print "[INFO] Starting Google+ Engine" source=b.open('https://plus.google.com/s/'+" ".join(d.values())+'/people') print "[INFO]Starting Parsing" from bs4 import BeautifulSoup as bs #source=open("googleDummy","r").read() divs=bs(source).findAll("div",{"class":"Osd Hfb"}) print "[INFO] Found "+str(len(divs))+" profiles" i=1 for d in divs: print "[INFO] Grabbing "+str(i)+" profile" temp={} temp["name"]=d.find("a",{"class":"R9a Kra LXa AIa ob"}).text temp["institution"]=d.find("div",{"class":"q0a axa"}).text temp["user_ids"]=d.find("a",{"class":"R9a Kra LXa AIa ob"})["href"].replace("/","") temp["images"]=d.find("img",{"class":"we"})["src"] temp["profile_url"]="https://plus.google.com/"+temp["user_ids"] abt_us=b.open(temp["profile_url"]+"/about") abt_us=str(filter(lambda x:ord(x)>31 and ord(x)<128,abt_us)) temp["friends"]=[] temp["tags"]=[] #Trying to grab friends try: t=abt_us.split("ob tv Ub")[1:] v=t[len(t)-1] index=t[len(t)-1].find("</a>") t.pop() d=''.join(t)+v[:index] a=bs(d) aas=[] a=a.findAll("div",{"class":"KfV4Rd Zqc"}) for j in a: aas.append(j.find("a").text) temp["friends"]=list(set(aas)) print "[INFO] got friends for "+str(i) except: print "[INFO] no friends for "+str(i)+" what a looner" #Trying to grab all basic info try: s=bs(abt_us.replace("</"," </")).findAll("div",{"class":"Uia"}) for ss in s: temp["tags"]=temp["tags"]+ss.text.lower().split() temp["tags"]=[str(x).strip() for x in list(set(temp["tags"]))] temp["email"]="" temp["mobile"]="" if temp["tags"].index("male")>=0: temp["gender"]="male" elif temp["tags"].index("female")>=0: temp["gender"]="female" import re for f in temp["tags"]: if len(re.findall(".*@.*",f))>=1: temp["email"]=f if len(re.findall("\d{10}",f))>=1: temp["mobile"]=f print "[INFO] got some basic info for "+str(i) except Exception as e: print e print "[INFO] no basic info for "+str(i) i+=1 people.append(temp)
'74.221.211.12:3128', '66.35.68.146:7808' ] while True: #last_saved_state = db.read_last_saved_state() last_saved_cred_id = 0 #last_current_state = db.read_last_row_current_states() #last_login_cred_id_current_state = last_current_state[5] #if last_saved_state: # if last_saved_state[1] == 13: # last_saved_cred_id = 0 # else: # last_saved_cred_id = last_saved_state[1] - 1 browser = Browser() browser.OpenURL('http://www.ip-adress.com/proxy_list/?k=time&d=desc') page = browser.GetPage() proxy_ip_list = Parser.parse_proxy_ip_address(page) proxy_ip_list = proxy_ip_addressess print "Proxy IP Found: " print len(proxy_ip_list) cred_list = db.get_cred_list(start=45,limit=1000) if not cred_list: print "Cred List %s" % str(last_saved_cred_id) break for each_cred in cred_list: try: print 'Entered %s' % each_cred[1]
def OpenGui(self): self.mGuiBrowser=Browser.cBrowser(self.mData, BrowserOA22.cOpenAccessBrowserHints(), 0,self.mCloseFun) self.mGuiBrowser.Display()
def statistics_for_lemma_expanded(lemma, PER_DEFINITION_DETAILS = False, PER_DEFINITION_DETAILS_EXPANDED = False): """Given a lemma it returns ???""" # PER_DEFINITION_DETAILS_EXPANDED presupposes PER_DEFINITION_DETAILS if PER_DEFINITION_DETAILS_EXPANDED: PER_DEFINITION_DETAILS = True result = {} def_ids = [] pages = lemma_pages(lemma) for i in xrange(1, pages + 1): doc = lemma_page(lemma, i) # Get all the ids for the definitions def_ids_in_page = [ x.replace('tools_', '') for x in doc.xpath("//td[@id='content']/table[@id='entries']/tr/td[@class='tools']/attribute::id") ] def_ids += def_ids_in_page if PER_DEFINITION_DETAILS: for def_id in def_ids_in_page: definition = {} if PER_DEFINITION_DETAILS_EXPANDED: # Pick up the DOM only for the definition definition_dom = doc.xpath("//td[@id='content']/table[@id='entries']/tr/td[@class='tools' and @id='tools_%s']/../following-sibling::tr[position() = 1]" % def_id)[0] # Determine tags definition['tags'] = definition_dom.xpath("./td[@class='text']/div[@class='greenery']/a[starts-with(@href, '/define.php?term=')]/text()") # Determine author author = definition_dom.xpath("./td[@class='text']/div[@class='greenery']/a[starts-with(@href, '/author.php?author=')]/text()") if len(author) == 0: author = "anonymous" else: author = author[0] definition['author'] = author # Determine date, if possible date = definition_dom.xpath("./td[@class='text']/div[@class='greenery']/span[@class='date']/text()") if len(date) == 0: date = "unknown" else: date = date[0].strip() definition['date'] = date definition['votes_up'] = VOTES_PLACEHOLDER definition['votes_down'] = VOTES_PLACEHOLDER result["defn_" + def_id] = definition # After we are done with fetching all the definition ids, fetch the votes (altogether) votes_regex = re.compile('Uncacheable.thumbs_update\(\{' + '((' + '"current_vote":""|' + '"thumbs_up":(?P<up>[0-9]*)|' + '"id":(?P<id>[0-9]*)|' + '"thumbs_down":(?P<down>[0-9]*)' + '),?)*' + '\}\);') votes = Browser.fetch('http://www.urbandictionary.com/uncacheable.php?ids=' + ','.join(def_ids)) total_votes_up = 0 total_votes_down = 0 for x in votes_regex.finditer(votes): def_id = x.group('id') votes_up = int(x.group('up')) votes_down = int(x.group('down')) if PER_DEFINITION_DETAILS: result["defn_" + def_id]['votes_up'] = votes_up result["defn_" + def_id]['votes_down'] = votes_down total_votes_up += votes_up total_votes_down += votes_down result['count_defs'] = len(def_ids) result['tags'] = lemma_page(lemma, 1).xpath("//td[@id='content']//span[@id='tags']/a/text()") result['total_votes_up'] = total_votes_up result['total_votes_down'] = total_votes_down result['total_votes'] = total_votes_up + total_votes_down return result
class RssGUI(QtGui.QWidget): StyleSheet = """ QGroupBox{ background-color: #0080FB; } QWidget[contenedor="true"]{ background-color: #e2e4e6; border: 0px; } QLineEdit{ color: #0080FB; font-size: 22px; font-weight:bold; margin: 0px; padding: 5px; border: 0px; background-color:#e2e4e6; } QLabel[noticias="true"]{ font-size: 30px; padding: 1px; } QTextEdit { background-color:white; border-radius: 8px; border: 1px solid white; color: black; font-size: 18px; margin: 0px; padding: 5px; } """ def __init__(self, parent = None): super(RssGUI, self).__init__(parent) self.showMaximized() self.setupUi(self) self.setStyleSheet(RssGUI.StyleSheet) def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(555, 422) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(246, 244, 242)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) Form.setPalette(palette) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8("images/rss.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) Form.setWindowIcon(icon) self.verticalLayout = QtGui.QVBoxLayout(Form)#contenedor de todos los elementos de la GUI self.verticalLayout.setContentsMargins(0,0,0,0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) #Barra de Menu self.horizontalLayout = QtGui.QHBoxLayout()# contenedor de la barra de opciones self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) #Boton Noticias self.buttonHome = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonHome.sizePolicy().hasHeightForWidth()) self.buttonHome.setSizePolicy(sizePolicy) self.buttonHome.setText(_fromUtf8("")) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(_fromUtf8("images/home.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonHome.setIcon(icon1)#boton de home self.buttonHome.setIconSize(QtCore.QSize(35, 35)) self.buttonHome.setObjectName(_fromUtf8("buttonHome")) self.horizontalLayout.addWidget(self.buttonHome) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum)) self.connect(self.buttonHome,SIGNAL("clicked()"),self.runThread) #Boton Agregar Proveedor self.buttonAdd = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonAdd.sizePolicy().hasHeightForWidth()) self.buttonAdd.setSizePolicy(sizePolicy) self.buttonAdd.setText(_fromUtf8("")) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(_fromUtf8("images/add.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonAdd.setIcon(icon2) self.buttonAdd.setIconSize(QtCore.QSize(32, 32)) self.buttonAdd.setObjectName(_fromUtf8("buttonAdd")) self.horizontalLayout.addWidget(self.buttonAdd) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum)) #Boton Quitar Proveedor """ self.buttonDecrease = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonDecrease.sizePolicy().hasHeightForWidth()) self.buttonDecrease.setSizePolicy(sizePolicy) self.buttonDecrease.setText(_fromUtf8("")) icon3 = QtGui.QIcon() icon3.addPixmap(QtGui.QPixmap(_fromUtf8("images/decrease.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonDecrease.setIcon(icon3) self.buttonDecrease.setIconSize(QtCore.QSize(32, 32)) self.buttonDecrease.setObjectName(_fromUtf8("buttonDecrease")) self.horizontalLayout.addWidget(self.buttonDecrease) spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem4) """ self.buttonConfig = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonConfig.sizePolicy().hasHeightForWidth()) self.buttonConfig.setSizePolicy(sizePolicy) self.buttonConfig.setText(_fromUtf8("")) icon4 = QtGui.QIcon() icon4.addPixmap(QtGui.QPixmap(_fromUtf8("images/config.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonConfig.setIcon(icon4) self.buttonConfig.setIconSize(QtCore.QSize(32, 32)) self.buttonConfig.setObjectName(_fromUtf8("buttonConfig")) self.horizontalLayout.addWidget(self.buttonConfig) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) #Grupo de Widgets de la barra self.barra=QtGui.QGroupBox() self.barra.setLayout(self.horizontalLayout) self.barra.setContentsMargins(0,0,0,0) self.verticalLayout.addWidget(self.barra)#se agrega la barra a la GUI self.scroll = QScrollArea() self.verticalLayout.addWidget(self.scroll) self.progress = QtGui.QProgressBar(self) self.progress.setGeometry(200,80,250,20) #self.feeds=QtGui.QGroupBox() #self.feeds.setTitle("Noticias") self.feeds=QtGui.QWidget() self.feeds.setProperty("contenedor",True) self.containerFeeds=QVBoxLayout() noticias=QLabel("Noticias") noticias.setProperty("noticias", True) self.containerFeeds.addWidget(noticias) self.feeds.setLayout(self.containerFeeds) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) #hilos proveedores self.pool=PoolThreads("threads.json")#carga el pool de hilos self.clock=None self.connect(self.pool.getConsumerThread(),SIGNAL("updateNews(PyQt_PyObject)"),self.updateData) #cuando el hilo consumidor extraiga datos del buffer se genera un evento que es manejado por la interfaz self.vT = VentanaTools(self) self.vP = VentanaProveedor(self) self.dP = DeleteProveedor(self) # conecciones self.buttonAdd.pressed.connect(self.openVentanaProveedor) self.buttonConfig.pressed.connect(self.openVentanaTools) #self.buttonDecrease.pressed.connect(self.openDeleteProveedor) self.connect(self.vT,SIGNAL("getTime(PyQt_PyObject)"),self.changeTime) self.flagScroll=True#habilitar scroll self.loadPage=[False]#cargar pagina en browser self.browser=Browser(self.loadPage) self.manageTime() self.center() self.runThread()#manda a descargar informacion a los hilos productores def runThread(self): self.pool.startToWork() def changeTime(self,time):#configuracion para cambiar el tiempo del pool de hilos self.pool.setTime(time) print("El tiempo se ha cambiado") def manageTime(self): t=Time()#este objeto permite extraer el tiempo actual del sistema if self.clock==None: #se envia al hilo el tiempo actual y el maximo tiempo de espera self.clock=ClockThread(t.getCurrentTime(),self.pool.getTime())#obtiene el tiempo actual self.connect(self.clock,SIGNAL("timeOver()"),self.timeEnding) else: self.clock.setMaxTime(self.pool.getTime()) self.clock.setStartTime(t.getCurrentTime()) #manda a ejecutar un hilo que consultara el tiempo self.clock.start() def timeEnding(self): print("Time is Over") self.pool.startToWork() self.manageTime()#reinicia el reloj def updateData(self,feedNew): containerFeedNew=QGridLayout() title=FeedTitle(feedNew.getTitle()) title.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) title.setUrl(feedNew.getLink()) self.connect(title,SIGNAL("clicked()"),self.showNew) description=QTextEdit(feedNew.getDescripcion()) description.setReadOnly(True) containerFeedNew.addWidget(title,0,0) containerFeedNew.addWidget(description,1,0) self.containerFeeds.addLayout(containerFeedNew) if self.flagScroll: self.flagScroll=False self.scrollOn() def showNew(self): if not(self.loadPage[0]): title=self.sender() self.loadPage[0]=True url=title.getUrl() if len(url)>0: self.browser.openPage(url) def scrollOn(self): self.scroll.setWidget(self.feeds) self.scroll.setWidgetResizable(True) def center(self): frameGm = self.frameGeometry() screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) @QtCore.pyqtSlot() def openVentanaProveedor(self): self.vP.show() @QtCore.pyqtSlot() def openVentanaTools(self): self.vT.show() def openDeleteProveedor(self): self.dP.show() def retranslateUi(self, Form): Form.setWindowTitle(_translate("Form", "RSS Reader", None))
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(555, 422) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(246, 244, 242)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) Form.setPalette(palette) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8("images/rss.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) Form.setWindowIcon(icon) self.verticalLayout = QtGui.QVBoxLayout(Form)#contenedor de todos los elementos de la GUI self.verticalLayout.setContentsMargins(0,0,0,0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) #Barra de Menu self.horizontalLayout = QtGui.QHBoxLayout()# contenedor de la barra de opciones self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) #Boton Noticias self.buttonHome = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonHome.sizePolicy().hasHeightForWidth()) self.buttonHome.setSizePolicy(sizePolicy) self.buttonHome.setText(_fromUtf8("")) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(_fromUtf8("images/home.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonHome.setIcon(icon1)#boton de home self.buttonHome.setIconSize(QtCore.QSize(35, 35)) self.buttonHome.setObjectName(_fromUtf8("buttonHome")) self.horizontalLayout.addWidget(self.buttonHome) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum)) self.connect(self.buttonHome,SIGNAL("clicked()"),self.runThread) #Boton Agregar Proveedor self.buttonAdd = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonAdd.sizePolicy().hasHeightForWidth()) self.buttonAdd.setSizePolicy(sizePolicy) self.buttonAdd.setText(_fromUtf8("")) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(_fromUtf8("images/add.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonAdd.setIcon(icon2) self.buttonAdd.setIconSize(QtCore.QSize(32, 32)) self.buttonAdd.setObjectName(_fromUtf8("buttonAdd")) self.horizontalLayout.addWidget(self.buttonAdd) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum)) #Boton Quitar Proveedor """ self.buttonDecrease = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonDecrease.sizePolicy().hasHeightForWidth()) self.buttonDecrease.setSizePolicy(sizePolicy) self.buttonDecrease.setText(_fromUtf8("")) icon3 = QtGui.QIcon() icon3.addPixmap(QtGui.QPixmap(_fromUtf8("images/decrease.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonDecrease.setIcon(icon3) self.buttonDecrease.setIconSize(QtCore.QSize(32, 32)) self.buttonDecrease.setObjectName(_fromUtf8("buttonDecrease")) self.horizontalLayout.addWidget(self.buttonDecrease) spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem4) """ self.buttonConfig = QtGui.QPushButton(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonConfig.sizePolicy().hasHeightForWidth()) self.buttonConfig.setSizePolicy(sizePolicy) self.buttonConfig.setText(_fromUtf8("")) icon4 = QtGui.QIcon() icon4.addPixmap(QtGui.QPixmap(_fromUtf8("images/config.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.buttonConfig.setIcon(icon4) self.buttonConfig.setIconSize(QtCore.QSize(32, 32)) self.buttonConfig.setObjectName(_fromUtf8("buttonConfig")) self.horizontalLayout.addWidget(self.buttonConfig) self.horizontalLayout.addItem( QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) #Grupo de Widgets de la barra self.barra=QtGui.QGroupBox() self.barra.setLayout(self.horizontalLayout) self.barra.setContentsMargins(0,0,0,0) self.verticalLayout.addWidget(self.barra)#se agrega la barra a la GUI self.scroll = QScrollArea() self.verticalLayout.addWidget(self.scroll) self.progress = QtGui.QProgressBar(self) self.progress.setGeometry(200,80,250,20) #self.feeds=QtGui.QGroupBox() #self.feeds.setTitle("Noticias") self.feeds=QtGui.QWidget() self.feeds.setProperty("contenedor",True) self.containerFeeds=QVBoxLayout() noticias=QLabel("Noticias") noticias.setProperty("noticias", True) self.containerFeeds.addWidget(noticias) self.feeds.setLayout(self.containerFeeds) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) #hilos proveedores self.pool=PoolThreads("threads.json")#carga el pool de hilos self.clock=None self.connect(self.pool.getConsumerThread(),SIGNAL("updateNews(PyQt_PyObject)"),self.updateData) #cuando el hilo consumidor extraiga datos del buffer se genera un evento que es manejado por la interfaz self.vT = VentanaTools(self) self.vP = VentanaProveedor(self) self.dP = DeleteProveedor(self) # conecciones self.buttonAdd.pressed.connect(self.openVentanaProveedor) self.buttonConfig.pressed.connect(self.openVentanaTools) #self.buttonDecrease.pressed.connect(self.openDeleteProveedor) self.connect(self.vT,SIGNAL("getTime(PyQt_PyObject)"),self.changeTime) self.flagScroll=True#habilitar scroll self.loadPage=[False]#cargar pagina en browser self.browser=Browser(self.loadPage) self.manageTime() self.center() self.runThread()#manda a descargar informacion a los hilos productores
def words_page(character, page): params = {} params['character'] = character params['page'] = page return etree.parse(StringIO(Browser.fetch('http://www.urbandictionary.com/browse.php?' + urlencode(params))), parser)