ro  fr  en  es  pt  ar  zh  hi  de  ru
ART 2.0 ART 3.0 ART 4.0 ART 5.0 ART 6.0 Pinterest

पायथन: उन लिंक को ढूंढें जो एक ही फ़ोल्डर में अन्य HTML पृष्ठों में दोहराए जाते हैं

On Noiembrie 23, 2021, in Leadership and Attitude, by Neculai Fantanaru

आप यहां पूरा कोड देख सकते हैं:Https: // passatin.com / v1mdx0 चाहिए

इंस्टॉलपायथन

कई HTML लिंक हैं, सभी अनुभाग में शामिल हैंप्रति

सभी एचटीएमएल फाइलों में यह संरचना नीचे है, केवल लिंक अलग हैं। तो नीचे दिए गए लिंक में से कोई भी अन्य HTML पृष्ठों (फ्लैग सेक्शन में) में दोहराया जाना चाहिए।

और सभी लिंक के साथ शुरू होता है Https: // उसे परेशान करने के लिए पैदा हुआ .com /

कोडुल: सभी HTML फ़ाइलें (उसी फ़ोल्डर से) खोजें जिनमें अनुभाग में समान लिंक हैं कोड पुनरावर्ती लिंक और HTML पृष्ठों को भी दिखाएगा जहां वे हैं

import sys
import re
import os


def read_text_from_file(file_path):
    """
    Aceasta functie returneaza continutul unui fisier.
    file_path: calea catre fisierul din care vrei sa citesti
    """
    with open(file_path, encoding='utf8') as f:
        text = f.read()
        return text


def write_to_file(text, file_path):
    """
    Aceasta functie scrie un text intr-un fisier.
    text: textul pe care vrei sa il scrii
    file_path: calea catre fisierul in care vrei sa scrii
    """
    with open(file_path, 'wb') as f:
        f.write(text.encode('utf8', 'ignore'))


def extragere_linkuri(cale_fisier_html):
    text_html = read_text_from_file(cale_fisier_html)
    flags_pattern = re.compile('([\s\S]*?)[\s\S]*?')
    text_flags = re.findall(flags_pattern, text_html)
    if len(text_flags) != 0:
        text_flags = text_flags[0]
        link_pattern = 'href=\"(.*?)\"'
        links = re.findall(link_pattern, text_flags)
        links = list(set(links))
    return links

def verificare_fisiere(cale_folder_fisiere, cale_fisier_rezultat):
    cai_fisiere = list()
    lista_linkuri = list()
    for f in os.listdir(cale_folder_fisiere):
            if f.endswith('.html'):
                cale_fisier_html = cale_folder_fisiere + "\\" + f
                links = extragere_linkuri(cale_fisier_html)
                cai_fisiere.append(cale_fisier_html)
                lista_linkuri.append(links)
            else:
                continue
    rezultate = ''
    for i in range(0, len(lista_linkuri)):
        for j in range(i + 1, len(lista_linkuri)):
            if len(set(lista_linkuri[i]).intersection(set(lista_linkuri[j]))) != 0:
                rezultate += "Fisiere comune: \n"
                print("Fisiere comune: ")
                for link in set(lista_linkuri[i]).intersection(set(lista_linkuri[j])):
                    rezultate += link
                    rezultate += '\n'
                    print(link, '\n')
                rezultate += 'Fisier {} ARE LINKURI IN COMUN CU: {}'.format(cai_fisiere[i], cai_fisiere[j])
                rezultate += '\n\n'
                print('Fisier {} ARE LINKURI IN COMUN CU: {}'.format(cai_fisiere[i], cai_fisiere[j]))
                print('\n\n')
    limba = "en" # BEBE AICI VEZI EXACT FOLDERUL, sa lasi doar "" daca vrei sa cauti in limba romana
    rezultate += "==========={}============\n\n".format(limba.upper())
    print("==========={}============\n\n".format(limba.upper()))
    for i in range(0, len(lista_linkuri)):
        for j in range(i + 1, len(lista_linkuri)):
            linkuri_limba = list()
            if len(set(lista_linkuri[i]).intersection(set(lista_linkuri[j]))) != 0:
                for link in set(lista_linkuri[i]).intersection(set(lista_linkuri[j])):
                    if limba in link.split('/'):
                        linkuri_limba.append(link)
                if len(linkuri_limba) != 0:
                    rezultate += "Fisiere comune: \n"

                    print("Fisiere comune: ")
                    for link in linkuri_limba:
                        rezultate += link
                        rezultate += '\n'
                        print(link, '\n')
                        rezultate += 'Fisier {} ARE LINKURI IN COMUN CU: {}'.format(cai_fisiere[i], cai_fisiere[j])
                        rezultate += '\n\n'
                        print('Fisier {} ARE LINKURI IN COMUN CU: {}'.format(cai_fisiere[i], cai_fisiere[j]))
                        print('\n\n')

    write_to_file(rezultate, cale_fisier_rezultat)

if __name__ == "__main__":
    verificare_fisiere("c:\\Folder1", "c:\\Folder1\\rezultate.txt")
    # verificare_fisiere("e:\\Carte\\BB\\17 - Site Leadership\\Principal\\en", "c:\\Folder1\\rezultate.txt")

That's all folks.

If you like my code, then make me a favor: translate your website into Romanian, "ro".

इसके अलावा, अन्य पायथन कोड देखें:संस्करण 2इस कोड यासंस्करण 3यासंस्करण 4यासंस्करण 5यासंस्करण 6


Latest articles accessed by readers:

  1. An Eye To See And A Mind To Understand
  2. Turn Towards Me With An Eye Full Of Your Own Gaze
  3. The Snapshot Of Magic In God's Universe
  4. Rhythm Of My Heart

Donate via Paypal

Alternate Text

RECURRENT DONATION

Donate monthly to support
the NeculaiFantanaru.com project

SINGLE DONATION

Donate the desired amount to support
the NeculaiFantanaru.com project

Donate by Bank Transfer

Account Ron: RO34INGB0000999900448439

Open account at ING Bank

Join The Neculai Fantanaru Community



* Note: If you want to read all my articles in real time, please check the romanian version !

decoration
About | Site Map | Partners | Feedback | Terms & Conditions | Privacy | RSS Feeds
© Neculai Fântânaru - All rights reserved