python - Convert XPath to Beautiful Soup -
i have page has tag
<img alt="1ee7aca0cf5b0132dd7a005056a9545d" src="http://assets.amuniversal.com/1ee7aca0cf5b0132dd7a005056a9545d">
i know xpath -
//*[@id="content"]/div[2]/p/a/img
how access tag , src of tag using beautifulsoup?
you can try convert xpath expression css selector expression, , use beautifulsoup select()
method accept css selector expression parameter :
soup = beautifulsoup("your html source") result = soup.select("#content > div:nth-of-type(2) > p > > img")
Comments
Post a Comment