TestXml_alpha

 avatar
unknown
python
2 years ago
672 B
4
Indexable
import requests
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET

# Request the web page
url = "https://global.jaxa.jp/projects/result.html"
response = requests.get(url)

# Parse the web page content
soup = BeautifulSoup(response.content, "html.parser")

# Extract the desired information
missions = soup.find_all("tr")

# Create an XML file
root = ET.Element("missions")

for mission in missions:
    mission_element = ET.SubElement(root, "mission")

    tds = mission.find_all("td")
    for td in tds:
        details = ET.SubElement(mission_element, "details")
        details.text = td.text

tree = ET.ElementTree(root)
tree.write("missionsTest_3.xml")
Editor is loading...