ro  fr  en  es  pt  ar  zh  hi  de  ru
') span_nou ='' span = re.findall(span_pattern, articol_categorie) lista_span_nou = list()for i in range(len(span)): lista_span_nou.append(span_nou.format(span[i][0], span[i][1])) span_pattern = re.compile('') span = re.findall(span_pattern, articol_categorie)for i in range(len(span)): articol_categorie = articol_categorie.replace(span[i], lista_span_nou[i])#==== INLOCUIRE <td><span class="den_articol"> CU <td><span class="linkMare">====#==== Informatii fisier original ==== categ_link_title_pattern = re.compile('') categ_link_title = re.findall(categ_link_title_pattern, articol_categorie) print("Total {} ARTICOLE".format(len(categ_link_title))) categ_date_link_title_desc_pattern = re.compile('') categ_date_link_title_desc = re.findall(categ_date_link_title_desc_pattern, articol_categorie) paragraf_pattern = re.compile('

(.*?)

'
) paragraf = re.findall(paragraf_pattern, articol_categorie)#=== citeste mai departe - buton === citeste_buton_pattern = re.compile('
citeşte mai departe ') citeste_buton = re.findall(citeste_buton_pattern, articol_categorie) read_more_buton_pattern = re.compile('
read more ') read_more_buton = re.findall(read_more_buton_pattern, articol_categorie) # === Informatii index2 === articol_categorie_index2_pattern = re.compile('([\s\S]*?)') articol_categorie_index2 = re.findall(articol_categorie_index2_pattern, text_html_model) if len(articol_categorie_index2) != 0: articol_categorie_index2 = articol_categorie_index2[0] # trebuie inlocuit cu toate categoriile din fisierul original # citire template pentru categorie din index2.html template_categorie = read_text_from_file("C:\\Folder1\\template_categorie.txt") # h3 => title + description h3_pattern = re.compile('

(.*?)

'
) h3 = re.findall(h3_pattern, template_categorie) h3 = h3[0] # dates section din index2.html dates_section_index2_pattern = re.compile('([\s\S]*?)') dates_section_index2 = re.findall(dates_section_index2_pattern, template_categorie) dates_section_index2 = dates_section_index2[0] date_index2_pattern = re.compile('(.*?)') # date date_index2 = re.findall(date_index2_pattern, dates_section_index2) date_index2 = date_index2[0] # link / title / description link_title_desc_index2_pattern = re.compile('(.*?)') link_title_desc_index2 = re.findall(link_title_desc_index2_pattern, dates_section_index2) link_title_desc_index2 = link_title_desc_index2[0] # paragraf paragraf_index2_pattern = re.compile('

(.*?)

'
) paragraf_index2 = re.findall(paragraf_index2_pattern, template_categorie) paragraf_index2 = paragraf_index2[0] # === read more === read_more_pattern = re.compile('read more') read_more = re.findall(read_more_pattern, template_categorie) read_more = read_more[0] butoane = list() if len(citeste_buton) > 0: butoane = citeste_buton else: butoane = read_more_buton for i in range(len(categ_link_title)): new_template = template_categorie # === facem replace cu informatiile din articolul original === new_template_1 = new_template.replace(date_index2, categ_date_link_title_desc[i][0].replace(', in', '').strip()) new_template_2 = new_template_1.replace(link_title_desc_index2[0], categ_date_link_title_desc[i][1]) new_template_3 = new_template_2.replace(link_title_desc_index2[1], categ_date_link_title_desc[i][2]) new_template_4 = new_template_3.replace(link_title_desc_index2[2], categ_date_link_title_desc[i][3].lstrip()) new_template_5 = new_template_4.replace(paragraf_index2, paragraf[i]) new_template_6 = new_template_5.replace(read_more, butoane[i]) new_template_7 = new_template_6.replace(h3[0], categ_link_title[i][0]) new_template_8 = new_template_7.replace(h3[1], categ_link_title[i][1]) final_text = final_text + new_template_8 + '\n' text_html_model = text_html_model.replace(articol_categorie_index2, final_text) final_text = text_html_model # schimbare CATEGORIES index2 # preluare lista fisier html lista_pattern = re.compile('
    ([\s\S]*?)
'
) lista = re.findall(lista_pattern, text_html) if len(lista) != 0: lista = lista[0] elemente_lista_pattern = re.compile('
  • (.*?) \((.*?)\)
  • '
    ) elemente_lista = re.findall(elemente_lista_pattern, lista) if elemente_lista != 0: categories_pattern = re.compile('([\s\S]*?)') categories = re.findall(categories_pattern, final_text) if len(categories) != 0: categories = categories[0] elemente_lista_model_pattern = re.compile('
    ([\s\S]*?)
    '
    ) elemente_lista_model = re.findall(elemente_lista_model_pattern, categories) template_category = read_text_from_file('C:\\Folder1\\category-name.txt') for i in range(len(elemente_lista_model)): new_template_category = template_category a_pattern = re.compile('') a = re.findall(a_pattern, new_template_category)[0] p_pattern = re.compile('

    (.*?) (.*?)

    '
    ) p = re.findall(p_pattern, new_template_category)[0] new_template_category = new_template_category.replace(a[0], elemente_lista[i][0]) new_template_category = new_template_category.replace(a[1], elemente_lista[i][1]) new_template_category = new_template_category.replace(p[0], elemente_lista[i][2]) new_template_category = new_template_category.replace(p[1], elemente_lista[i][3]) # print(final_text) final_text = final_text.replace(elemente_lista_model[i], new_template_category) else: print("No categories + books start") else: print("Niciun element
  • .") else: print("Tag
  • ART 2.0 ART 3.0 ART 4.0 ART 5.0 ART 6.0 Pinterest

    पायथन: किसी वेबसाइट से दूसरे वेबसाइट डिज़ाइन में डेटा कैसे स्थानांतरित करें

    On March 24, 2022, in Leadership Quantum-XX, by Neculai Fantanaru

    आप यहां पूरा कोड देख सकते हैं:Https: // passatin.com / vcd vm ww देखें

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

    यह मेरी पुरानी वेबसाइट डिजाइन है। Basically, you need to select the information from the old tags (css classes) and copy it into the new tags (css classes).

    Alatura-te Comunitatii Neculai Fantanaru
    I WILL TRANSFER DATA TO THIS NEW WEBSITE:
    Alatura-te Comunitatii Neculai Fantanaru

     

    ------- पायथन कोड: ---------

    #-------------------------------------------------------------------------------
    # Author:      Neculai Fantanaru
    #
    # Created:     24/03/2022
    # Copyright:   (c) Neculai Fantanaru
    # Licence:     <your licence>
    #-------------------------------------------------------------------------------
    
    import os
    import re
    
    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 copiaza_continut_html(cale_fisier_html, cale_fisiere_gata): # astea sunt argumentele functiei, adica cand apelez functia
        # citesti textul din fisierul html
        text_html = read_text_from_file(cale_fisier_html)
        final_text = ''
    
        # === fisier html vechi ===
        articol_categorie_pattern = re.compile('([\s\S]*?)')
        articol_categorie = re.findall(articol_categorie_pattern, text_html)
        if len(articol_categorie) != 0:
            # === citire fisier model - index2.html ===
            text_html_model = read_text_from_file("C:\\Folder1\\index2.html")
            articol_categorie = articol_categorie[0]
    
            # ==== INLOCUIRE <td><span class="den_articol"> CU <td><span class="linkMare"> ====
            span_pattern = re.compile('
    (.*?) {} .*? (.*?)(.*?)(.*?), by Neculai Fantanaru (.*?), in ) date = re.findall(date_pattern, text_articol_model_old) if len(date) != 0: date = date[0] # MODIFICARE 09/03 date_section_pattern = re.compile('([\s\S]*?)') date_section = re.findall(date_section_pattern, text_html_model_6) if len(date_section) > 0: date_section = date_section[0] date_pattern_model = re.compile('(.*?)') date_model = re.findall(date_pattern_model, date_section) if len(date_model) != 0: date_model = date_model[0] text_html_model_7 = text_html_model_6.replace(date_model, date) final_text = text_html_model_7 else: print('No date in model.') else: print("No date section: ") else: print("No date.") # schimbare SECTION section_pattern_model = re.compile('(.*?)') section_model = re.findall(section_pattern_model, text_html_model_7) # print(section_model) if len(section_model) != 0: section_model = section_model[0] section_pattern = re.compile('(.*?)') section = re.findall(section_pattern, text_articol_model_old) if len(section) != 0: section = section[0] text_html_model_8 = text_html_model_7.replace(section_model[0], section[0]) text_html_model_9 = text_html_model_8.replace(section_model[1], section[1]) text_html_model_10 = text_html_model_9.replace(section_model[2], section[2]) final_text = text_html_model_10 else: print("No section.") else: print("No section model.") # schimbare CATEGORIES # preluare lista fisier html lista_pattern = re.compile('
      ([\s\S]*?)
    '
    ) lista = re.findall(lista_pattern, text_html) if len(lista) != 0: lista = lista[0] elemente_lista_pattern = re.compile('
  • (.*?) \((.*?)\)
  • '
    ) elemente_lista = re.findall(elemente_lista_pattern, lista) if elemente_lista != 0: categories_pattern = re.compile('([\s\S]*?)') categories = re.findall(categories_pattern, text_html_model_10) if len(categories) != 0: categories = categories[0] elemente_lista_model_pattern = re.compile('
    ([\s\S]*?)
    '
    ) elemente_lista_model = re.findall(elemente_lista_model_pattern, categories) template_category = read_text_from_file('C:\\Folder1\\category-name.txt') for i in range(len(elemente_lista_model)): new_template_category = template_category a_pattern = re.compile('') a = re.findall(a_pattern, new_template_category)[0] p_pattern = re.compile('

    (.*?) (.*?)

    '
    ) p = re.findall(p_pattern, new_template_category)[0] new_template_category = new_template_category.replace(a[0], elemente_lista[i][0]) new_template_category = new_template_category.replace(a[1], elemente_lista[i][1]) new_template_category = new_template_category.replace(p[0], elemente_lista[i][2]) new_template_category = new_template_category.replace(p[1], elemente_lista[i][3]) # print(final_text) final_text = final_text.replace(elemente_lista_model[i], new_template_category) # print("==========================") # print(final_text) text_html_model_14 = final_text else: print("No categories + books start") else: print("Niciun element
  • .") else: print("Tag
  • decoration
    About | Site Map | Partners | Feedback | Terms & Conditions | Privacy | RSS Feeds
    © Neculai Fântânaru - All rights reserved