“Python BeautifulSoup Xpath” Réponses codées

xpath belle

from bs4 import BeautifulSoup
from lxml import etree
import requests

# Test url and xpath
URL = "https://en.wikipedia.org/wiki/Nike,_Inc."
xpath_address = """//*[@id="firstHeading"]"""

response = requests.get(URL)
soup = BeautifulSoup(response.content, "html.parser")
dom = etree.HTML(str(soup))
print(dom.xpath(xpath_address)[0].text)
Thebetta

Python BeautifulSoup Xpath

try:
    # Python 2
    from urllib2 import urlopen
except ImportError:
    from urllib.request import urlopen
from lxml import etree

url =  "http://www.example.com/servlet/av/ResultTemplate=AVResult.html"
response = urlopen(url)
htmlparser = etree.HTMLParser()
tree = etree.parse(response, htmlparser)
tree.xpath(xpathselector)
dEN5

Réponses similaires à “Python BeautifulSoup Xpath”

Questions similaires à “Python BeautifulSoup Xpath”

Plus de réponses similaires à “Python BeautifulSoup Xpath” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code