Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

xpath beautifulsoup

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)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #xpath #beautifulsoup
ADD COMMENT
Topic
Name
9+5 =