我正试图用BeaurifulSoup从一页纸上搜集信息,上面有律师的名字
#importing libraries
from urllib.request import urlopen
from bs4 import BeautifulSoup
import requests
下面是嵌套在HTML标记中的每个律师的姓名示例
</a>
<div class="person-info search-person-info people-search-person-info">
<div class="col person-name-position">
<a href="https://www.foxrothschild.com/richard-s-caputo/">
Richard S. Caputo
</a>
我试着用下面的脚本提取每个律师的名字
'a'
作为标签和“
col person-name-position
“作为班级。但似乎没用。相反,它会打印出一个空列表。
page=requests.get("https://www.foxrothschild.com/people/?search%5Bname%5D=&search%5Bkeyword%5D=&search%5Boffice%5D=&search%5Bpeople-position%5D=&search%5Bpeople-bar-admission%5D=&search%5Bpeople-language%5D=&search%5Bpeople-school%5D=Villanova+University+School+of+Law&search%5Bpractice-area%5D=") #insert page here
soup=BeautifulSoup(page.content,'html.parser')
#print(soup.prettify())
find_name=soup.find_all('a',class_='col person-name-position')
print(find_name)