def doSingleArraysForUnevenNumberElements(self): stringOfMatchedDivParts = self.driver.find_elements_by_xpath( "//h3[contains(concat(' ', @class, ' '), 'r')]/following-sibling::div/div" ) for element in stringOfMatchedDivParts: elementParts = element.text.split('\n', 2) elementTitle = '' elementLink = '' elementDescription = '' if len(elementParts) == 3: elementLink = elementParts[0] elementTitle = elementParts[1] elementDescription = elementParts[2] elif len(elementParts) == 2: elementLink = elementParts[0] elementDescription = elementParts[1] if not re.search('^https?://', elementLink): elementLink = 'http://' + elementLink singleResultArray = [ elementTitle, elementLink, CleanText.replaceSingleQuotesWithTwoSingleQuotes( elementDescription) ] self.arrayOfGoogleLeads.append(singleResultArray)
def __init__(self, iefaLeadArray, fundingClassification, badScholarshipClassification): self.iefaLeadArray = iefaLeadArray self.fundingClassification = fundingClassification self.badScholarshipClassificaion = badScholarshipClassification self.db = SUDBConnect() self.fileSystemDB = SUDBConnect(destination='filesystem') self.name = self.iefaLeadArray[0] self.url = self.iefaLeadArray[1] self.url = CleanText.replaceSingleQuotesWithTwoSingleQuotes(self.url) self.sponsor = self.iefaLeadArray[2] self.submissionDeadline = self.iefaLeadArray[3] self.majors = self.iefaLeadArray[4] self.amount = self.iefaLeadArray[5] self.description = self.iefaLeadArray[6] self.otherCriteria = self.iefaLeadArray[7] self.numberAwards = self.iefaLeadArray[8] self.hostInstitution = self.iefaLeadArray[9] self.includes = self.iefaLeadArray[10] self.nationalityRequired = self.iefaLeadArray[11] self.hostCountries = self.iefaLeadArray[12] self.sourceWebsite = self.iefaLeadArray[13] self.sourceText = self.iefaLeadArray[14] self.date = time.strftime('%Y%m%d')
def doSingleArraysForSameNumberElements(self): for i in range(len(self.arrayOfTitles)): elementTitle = self.arrayOfTitles[i].text elementLink = self.arrayOfLinks[i] elementDescription = self.arrayOfDescriptions[i].text singleResultArray = [elementTitle, elementLink, CleanText.replaceSingleQuotesWithTwoSingleQuotes(elementDescription)] self.arrayOfGoogleLeads.append(singleResultArray)
def doSingleArraysForSameNumberElements(self): for i in range(len(self.arrayOfTitles)): elementTitle = self.arrayOfTitles[i].text elementLink = self.arrayOfLinks[i] elementDescription = self.arrayOfDescriptions[i].text singleResultArray = [ elementTitle, elementLink, CleanText.replaceSingleQuotesWithTwoSingleQuotes( elementDescription) ] self.arrayOfGoogleLeads.append(singleResultArray)
def doSingleArraysForUnevenNumberElements(self): stringOfMatchedDivParts = self.driver.find_elements_by_xpath( "//h3[contains(concat(' ', @class, ' '), 'r')]/following-sibling::div/div") for element in stringOfMatchedDivParts: elementParts = element.text.split('\n', 2) elementTitle = '' elementLink = '' elementDescription = '' if len(elementParts) == 3: elementLink = elementParts[0] elementTitle = elementParts[1] elementDescription = elementParts[2] elif len(elementParts) == 2: elementLink = elementParts[0] elementDescription = elementParts[1] if not re.search('^https?://', elementLink): elementLink = 'http://' + elementLink singleResultArray = [elementTitle, elementLink, CleanText.replaceSingleQuotesWithTwoSingleQuotes(elementDescription)] self.arrayOfGoogleLeads.append(singleResultArray)
def __init__(self, iefaLeadArray, fundingClassification, badScholarshipClassification): self.iefaLeadArray = iefaLeadArray self.fundingClassification = fundingClassification self.badScholarshipClassificaion = badScholarshipClassification self.db = SUDBConnect() self.fileSystemDB = SUDBConnect(destination='filesystem') self.name = self.iefaLeadArray[0] self.url = self.iefaLeadArray[1] self.url = CleanText.replaceSingleQuotesWithTwoSingleQuotes(self.url) self.sponsor = self.iefaLeadArray[2] self.submissionDeadline = self.iefaLeadArray[3] self.majors = self.iefaLeadArray[4] self.amount = self.iefaLeadArray[5] self.description = self.iefaLeadArray[6] self.otherCriteria = self.iefaLeadArray[7] self.numberAwards = self.iefaLeadArray[8] self.hostInstitution = self.iefaLeadArray[9] self.includes = self.iefaLeadArray[10] self.nationalityRequired = self.iefaLeadArray[11] self.hostCountries = self.iefaLeadArray[12] self.sourceWebsite = self.iefaLeadArray[13] self.sourceText = self.iefaLeadArray[14] self.date = time.strftime('%Y%m%d')