Skip to main content
se añadieron 185 caracteres en el cuerpo
Origen Enlace

¿Alguien podría ayudarme a mejorar mi expresión regular para encontrar todos los números de teléfono? No reconoce números de teléfono con paréntesis como (000) 0000 0000. ¡Gracias!

Someone could help me to improve my regex for find all the phone numbers? It does not recognize phone numbers with parentheses as (000) 0000 0000. Thank you!


   for line in url_file:
        try:
            u = line.strip()
            print(u)
            url = u
            response = requests.get(u)
            data = response.text
            soup = BeautifulSoup(data,'lxml')  
            dupl = set()

            phone = re.findall(r'\d{3}.\d{3}.\d{4}', data, re.MULTILINE)

            phn_1 = []

            if len(phone) == 0:
                print ("No phone number found.")
            else:
                count = 1
                for item in phone:
                    phn_1.append(item)
                    count += 1
                print (set(phn_1))   
                phn = (set(phn_1))   

Someone could help me to improve my regex for find all the phone numbers? It does not recognize phone numbers with parentheses as (000) 0000 0000. Thank you!


   for line in url_file:
        try:
            u = line.strip()
            print(u)
            url = u
            response = requests.get(u)
            data = response.text
            soup = BeautifulSoup(data,'lxml')  
            dupl = set()

            phone = re.findall(r'\d{3}.\d{3}.\d{4}', data, re.MULTILINE)

            phn_1 = []

            if len(phone) == 0:
                print ("No phone number found.")
            else:
                count = 1
                for item in phone:
                    phn_1.append(item)
                    count += 1
                print (set(phn_1))   
                phn = (set(phn_1))   

¿Alguien podría ayudarme a mejorar mi expresión regular para encontrar todos los números de teléfono? No reconoce números de teléfono con paréntesis como (000) 0000 0000. ¡Gracias!

Someone could help me to improve my regex for find all the phone numbers? It does not recognize phone numbers with parentheses as (000) 0000 0000. Thank you!


   for line in url_file:
        try:
            u = line.strip()
            print(u)
            url = u
            response = requests.get(u)
            data = response.text
            soup = BeautifulSoup(data,'lxml')  
            dupl = set()

            phone = re.findall(r'\d{3}.\d{3}.\d{4}', data, re.MULTILINE)

            phn_1 = []

            if len(phone) == 0:
                print ("No phone number found.")
            else:
                count = 1
                for item in phone:
                    phn_1.append(item)
                    count += 1
                print (set(phn_1))   
                phn = (set(phn_1))   

Origen Enlace

Regex for re.findall the phone numbers in websites don´t find phone numbers with brackets

Someone could help me to improve my regex for find all the phone numbers? It does not recognize phone numbers with parentheses as (000) 0000 0000. Thank you!


   for line in url_file:
        try:
            u = line.strip()
            print(u)
            url = u
            response = requests.get(u)
            data = response.text
            soup = BeautifulSoup(data,'lxml')  
            dupl = set()

            phone = re.findall(r'\d{3}.\d{3}.\d{4}', data, re.MULTILINE)

            phn_1 = []

            if len(phone) == 0:
                print ("No phone number found.")
            else:
                count = 1
                for item in phone:
                    phn_1.append(item)
                    count += 1
                print (set(phn_1))   
                phn = (set(phn_1))