【发布时间】:2019-07-01 19:40:21
【问题描述】:
我正在尝试从该网站获取手机/办公室电话号码信息:https://www.zillow.com/lender-profile/DougShoemaker/
我试过玩 bs4,但我只能得到第一个电话号码。我正在尝试获取办公室和手机号码。
from selenium import webdriver
from bs4 import BeautifulSoup
import time
#Chrome webdriver filepath...Chromedriver version 74
driver = webdriver.Chrome(r'C:\Users\mfoytlin\Desktop\chromedriver.exe')
driver.get('https://www.zillow.com/lender-profile/DougShoemaker/')
soup = BeautifulSoup(driver.page_source, 'html.parser')
time.sleep(2)
phoneNum = driver.find_element_by_class_name('zsg-list_definition')
trial = phoneNum.find_element_by_class_name('zsg-sm-hide')
print(trial.text)
【问题讨论】:
-
你有什么问题?当您尝试获取办公室和手机号码时会发生什么?您会得到不正确的结果、空结果还是错误消息?
-
我得到了第一个手机号码的正确结果,我只是不知道如何获得正确的路径或搜索才能获得提供的两个电话号码。上面的代码成功找到并打印了第一个电话号码,但我无法通过...标签的设置方式使得获取所需信息变得很棘手@John Gordon
标签: python selenium web-scraping beautifulsoup selenium-chromedriver