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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -