ازگر اور HTML فائلوں کا استعمال کرتے ہوئے سائٹ کا نقشہ XML کیسے تیار کریں neculai fantanaru (en)
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 فائلوں کا استعمال کرتے ہوئے سائٹ کا نقشہ XML کیسے تیار کریں

On February 16, 2022, in Python Scripts Examples, by Neculai Fantanaru

آپ یہاں مکمل کوڈ دیکھ سکتے ہیں:https: // پاساتبن .com/6gn gp bv6

انسٹال کریںازگرپھر ، پھر ، پھر

آپ کو درج ذیل فائلوں کی ضرورت ہے ، جو آپ اسی فولڈر میں ڈال سکتے ہیں:

- ایک خالی فائل بنائیں جسے کہتے ہیںRSS.XML(یہ وہ فائل ہے جس میں تمام HTML صفحات تیار ہوں گے)

- ایک فائل بنائیں جسے کہتے ہیںFinal_xml.txtجس میں آپ کو اس ٹیگ کو پہلی لائن پر کاپی کرنا ہے:

urlsetپیشن گوئی

- ایک فائل بنائیں جسے کہتے ہیںstart_xml.txtجس میں آپ کو شروع میں درج ذیل کوڈ رکھنا پڑے گا:

XML ورژن="1.0"انکوڈنگ="UTF-8"؟ >>
<<<<urlset
      xmlns: xsi="http: // woohoo. i 3.org/2001/xml اسکیما-انسٹینس" "
	  xmlns: xhtml="http: // woohoo. i 3.org/1999/xhtml"
      xsi: اسکیملوکیشن="HTTP: // woohoo .sitemaps.org/اسکیماس/سیٹ میپ/0.9 HTTP: // وو۔
      xmlns="HTTP: // woohoo .sitemaps.org/اسکیماس/سیٹ میپ/0.9" "" "" "" "" "" "" "" "" "" "پیشن گوئی	  	  
---- www.Check-domains.com سائٹ کا نقشہ جنریٹر ----پیشن گوئی

- ایک فائل بنائیں جسے کہتے ہیںmodel_xml.txtجہاں آپ کو شروع میں درج ذیل کوڈ کی ضرورت ہوگی:

  
    <سپن>https://your-website.com/example- افریقہ .html
    2021-11-30T17: 19: ZAT+00: 00
    <چینج فریک>ہفتہ وار
    <ترجیح>0.6400
  

ازگر کوڈ (اسے کہیں بھی محفوظ کریں ، صرف HTML فائلوں کے ساتھ اپنے فولڈر کے ساتھ راستہ تبدیل کریں)

import os
import re
import random
import unidecode


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 creeaza_fisier_xml():
    lista_nume_fisiere = preia_nume_fisiere_html(
        'e:\\YOUR-FOLDER-WITH-HTML-FILES',
        # files to ignore
        ['404-1.html', '404-2.html', '404-3.html']
    )
    start_xml = read_text_from_file('start_xml.txt')
    final_xml = read_text_from_file('final_xml.txt')
    model_xml = read_text_from_file('model_xml.txt')

    xml_text = start_xml + '\n'
    link_pattern = re.compile('(.*?)')
    link = re.findall(link_pattern, model_xml)
    if len(link) != 0:
        link = link[0]

    for nume_fisier in lista_nume_fisiere:
        model = model_xml
        model = model.replace(link, 'https://YOUR-WEBSITE.com/' + nume_fisier)
        xml_text = xml_text + model + '\n'

    xml_text = xml_text + final_xml

    write_to_file(xml_text, 'rss.xml')
    print("Scriere efectuata cu succes.")

def preia_nume_fisiere_html(folder_fisiere_html, lista_fisiere_de_ignorat):
    lista_nume_fisiere_html = list()
    for f in os.listdir(folder_fisiere_html):
            if f.endswith('.html'):
                lista_nume_fisiere_html.append(f)
    lista_finala = list()
    for f in lista_nume_fisiere_html:
        if f not in lista_fisiere_de_ignorat:
            lista_finala.append(f)
    return lista_finala

def main():
    creeaza_fisier_xml()

if __name__ == '__main__':
    main()

That's all folks.

اگر آپ کو میرا کوڈ پسند ہے تو ، براہ کرم اسے شیئر کریں

اس کوڈ کو دیکھیںپاور شیلیا ازگر کوڈزورژن 3یاورژن 4یاورژن 5

 


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