“Scraper BeautifulSoup Python HTML Valeur d'attribut” Réponses codées

Scraper BeautifulSoup Python HTML Valeur d'attribut

xmlData = None

with open('conf//test1.xml', 'r') as xmlFile:
    xmlData = xmlFile.read()

xmlDecoded = xmlData

xmlSoup = BeautifulSoup(xmlData, 'html.parser')

repElemList = xmlSoup.find_all('repeatingelement')

for repElem in repElemList:
    print("Processing repElem...")
    repElemID = repElem.get('id')
    repElemName = repElem.get('name')

    print("Attribute id = %s" % repElemID)
    print("Attribute name = %s" % repElemName)



# ==================================

>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup('<META NAME="City" content="Austin">')
>>> soup.find("meta", {"name":"City"})
<meta name="City" content="Austin" />
>>> soup.find("meta", {"name":"City"})['content']
u'Austin'
Alemhar

Python BeautifulSoup GET

xmlData = None

with open('conf//test1.xml', 'r') as xmlFile:
    xmlData = xmlFile.read()

xmlDecoded = xmlData

xmlSoup = BeautifulSoup(xmlData, 'html.parser')

repElemList = xmlSoup.find_all('repeatingelement')

for repElem in repElemList:
    print("Processing repElem...")
    repElemID = repElem.get('id')
    repElemName = repElem.get('name')

    print("Attribute id = %s" % repElemID)
    print("Attribute name = %s" % repElemName)
Cirex

Réponses similaires à “Scraper BeautifulSoup Python HTML Valeur d'attribut”

Questions similaires à “Scraper BeautifulSoup Python HTML Valeur d'attribut”

Plus de réponses similaires à “Scraper BeautifulSoup Python HTML Valeur d'attribut” dans HTML

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code