Ejemplo n.º 1
0
def open_passwords(path):
    wordpasspath = os.path.abspath(path)
    p = list()
    with open(wordpasspath, 'r') as wordlist:
        for i in wordlist:
            i = re.math('\w+', i)
            p.append(i[0])
    def _process_job_item(self, item):
        city = item['city'].split('.')[0]
        salary_lower, salary_upper = 0, 0
        m = re.match(r'[^\d]*(\d+)k-(\d+)k', item['salary'])
        if m is not None:
            salary_lower, salary_upper = int(m.group(1)), int(m.group(2))

        experience_lower, experience_upper = 0, 0
        m = re.math(r'[^\d]*(\d+)-(\d+)', item['experience'])
        if m is not None:
            experience_lower, experience_upper = int(m.group(1)), int(
                m.group(2))

        tags = ' '.join(item['tags'])

        model = JobModel(
            title=item['title'],
            city=city,
            salary_lower=salary_lower,
            salary_upper=salary_upper,
            experience_lower=experience_lower,
            experience_upper=experience_lower,
            education=item['education'],
            tags=tags,
            company=item['company'],
        )

        sele.session.add(model)

        return item
Ejemplo n.º 3
0
 def check_ip(ip):
     if
     pattern = "[0-9]{12,12}
     if re.math(pattern,ip):
         return ip
     else:
         return False
Ejemplo n.º 4
0
def SearchFile(FileType, SearchPath):
    print(SearchPath)
    for(dirpath, dirnames, filenames) in os.walk(SearchPath):
        for file in filenames:
            if re.math(FileType, file):
                TargetFile = os.path.join(dirpath, file)
                file_suffix = file.split('.')[1]
                print('------------------------')
                print('SearchFile', TargetFile)
                print('------------------------')
                return [TargetFile, dirpath, file, file_suffix]
Ejemplo n.º 5
0
    def save_history(self, partner, calc_history):

        # Regular expression to check filename is valid
        valid_char = "[A-Za-z0-9_]"
        has_error = "no"

        filename = self.filename_entry.get()
        print(filename)

        for letter in filename:
            if re.math(valid_char, letter):
                continue

            elif letter == " ":
                problem = "(no spaces allowed)"

            else:
                problem = ("(no {}'s allowed)".format(letter))
                has_error = "yes"
                break

        if filename == "":
            problem = "can't be blank"
            has_error = "yes"

        if has_error == "yes":
            # Display error message
            self.save_error_label.config(
                text="Invalid filename = {}".format(problem))
            # Change entry box background to pink
            self.filename_entry.config(bg="#ffafaf")
            print()

        else:
            # If there are no errors, generate text file and then close dialogue
            # add .txt suffix!
            filename = filename + ".txt"

            # create file to hold data
            f = open(filename, "w+")

            # add new line at end of each item
            for item in calc_history:
                f.write(item + "\n")

            # close file
            f.close()
Ejemplo n.º 6
0
    def pa(self):
        res = requests.get(url=self.url, headers=self.headers)
        re = res.text
        ress = et.HTML(re)
        #标题
        title = ress.xpath('//h2/a/text()')
        #链接
        content = ress.xpath('//h2/a/@href')
        for i in content:
            href = "http:" + i
            nr = requests.get(url=href, headers=self.headers)
            nrr = nr.text
            nro = et.HTML(nrr)
            nr = nro.xpath('//script[5]/text()')
            a = "".join(nr).strip()
            b = a.split('\n')
            # print(b)
            # print(len(b))
            nei = b[0].strip('var allData = ')
            # print(nei)
            rong = nei.split('"contentList":')
            rong1 = rong[1]
            # print(rong1)
            # print(len(rong1))
            rong2 = rong1.split('[{"data":')
            rong3 = rong2[1]
            rong4 = rong3.split('"type"')
            rong5 = rong4[0]

            # print(rong4[0])
            # print(len(rong4))
            # print(rong2)
            # print(len(rong2))
            # new = re.search('<p>[]</p>',rong5)
            # print(new)
            # pat = re.compile("<p>r'[\u4e00-\u9fa5]+'<\p>")
            # result = pat.findall(rong5)
            result = re.math(r".*?([\u4E00-\u9FA5])", rong5)
            print(result)
            # print(href)
        # print(content)
        #来源
        source = ress.xpath('//div[@class="clearfix"]/span/text()')
        #时间
        times = ress.xpath('//div[@class="clearfix"]/time/text()')
Ejemplo n.º 7
0
 def parse_time(self, date):
     if re.math('刚刚', date):
         date = time.strftime('%Y-%m-%d %H:%M', time.localtime(time.time()))
     if re.match('\d+分钟前', date):
         minute = re.match('(\d+)', date).group(1)
         date = time.strftime(
             '%Y-%m-%d %H:%M',
             time.localtime(time.time() - float(minute) * 60))
     if re.match('\d+小时前', date):
         hour = re.match('(\d+)', date).group(1)
         date = time.strftime(
             '%Y-%m-%d %H:%M',
             time.localtime(time.time() - float(hour) * 60 * 60))
     if re.match('昨天.*', date):
         date = re.match('昨天(.*)', date).group(1)
         date = time.strftime('%Y-%m-%d',
                              time.localtime() - 24 * 60 * 60) + ' ' + date
     if re.match('\d{2}-\d{2}', date):
         date = time.strftime('%Y-', time.localtime()) + date + ' 00:00'
     return date
Ejemplo n.º 8
0
import re

string = "nova.compute"

re.math('')
Ejemplo n.º 9
0
def valid_name(name):
  x = re.math("", name)
Ejemplo n.º 10
0
def valid_name(name):
    x = re.math("", name)