python - How do I run a BeaufiulSoup4 command in BeauifulSoup 3? -


i'm trying add new code larger project, code uses beauifulsoup4 , project used beautifulsoup 3.2.1. if try run beautifulsoup 3.2.1 on code error .parent commands exist in code. try upgrading project beauifulsoup4, errors failed test in part of project prefer not tamper with. supervisor told me it's against company policy have 2 different versions of same pip installed. there way me add .parent command beautifulsoup 3.2.1?

soup = beautifulsoup(response.content, 'html.parser') na = soup.find(id='pizza stores') links = na.parent.parent.find_all('a')

when try run code in beautifulsoup 3

typeerror: 'nonetype' object not callable

i changed changed beautifulsoup(response.content, 'html.parser') beautifulsoup(response.content) when trying run in beautifulsoup 3.

the problem not in parent, in find_all, should findall in bs3.

doc = '<html><body><div><div id="pizza stores"></div></div><a>link</a></body></html>' sp = beautifulsoup.beautifulsoup(doc) na = sp.find(id='pizza stores') na.parent.parent.findall('a')  out[44]: [<a>link</a>] 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -