我想在soccer matches website上检索下载链接。
使用以下脚本,我可以找到周围元素的位置:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://fullmatchsports.co/amiens-vs-psg-full-match-ligue-1-2018/')
soup = BeautifulSoup(driver.page_source, 'lxml')
download = driver.find_element_by_xpath('//*[@id="post-22276"]/div/div/p[3]/strong')
接下来,我想在“下载”中找到链接
links = download.findAll('a')
这将导致以下错误:
AttributeError: 'WebElement' object has no attribute 'findAll'
我不明白为什么它找不到这些类。如果检查页面,会发现这些类是“ strong”的一部分?
答案 0 :(得分:1)
使用硒或 BeautifulSoup :
let recorder = RPScreenRecorder.shared()
recorder.startCapture(handler: { [weak self](buffer, bufferType, err) in
// ...
}, completionHandler: { (error) in
// 1. If the user chooses "Dont'Allow", the error message will print "The user declined application recording". Outside of that if an actual error occurs something else will print
if let error = error {
print(error.localizedDescription)
print("The user choose Don't Allow")
return
}
// 2. Check the other 2 options
if self.recorder.isMicrophoneEnabled {
print("The user choose Record Screen & Microphone")
} else {
print("The user choose Record Screen Only")
}
})
是 BeautifulSoup 方法}, completionHandler: { (error) in
if let error = error as NSError? {
let rpRecordingErrorCode = RPRecordingErrorCode(rawValue: error.code)
self.errorCodeResponse(rpRecordingErrorCode)
}
})
func errorCodeResponse(_ error: RPRecordingErrorCode?) {
guard let error = error else { return }
switch error {
case .unknown:
print("Error cause unknown")
case .userDeclined:
print("User declined recording request.")
case .disabled:
print("Recording disabled via parental controls.")
case .failedToStart:
print("Recording failed to start.")
case .failed:
print("Recording error occurred.")
case .insufficientStorage:
print("Not enough storage available on the device.")
case .interrupted:
print("Recording interrupted by another app.")
case .contentResize:
print("Recording interrupted by multitasking and content resizing.")
case .broadcastInvalidSession:
print("Attempted to start a broadcast without a prior session.")
case .systemDormancy:
print("Recording forced to end by the user pressing the power button.")
case .entitlements:
print("Recording failed due to missing entitlements.")
case .activePhoneCall:
print("Recording unable to record due to active phone call.")
default: break
}
}
是硒 IEnumerable<double> numbers = GetNumbers();
var queue = new Queue<double>();
foreach (var number in numbers)
{
var computed = Compute(number);
queue.Enqueue(computed);
}
,没有findAll
方法。 这是错误的原因。这里是如何获取Selenium的下载链接:
download = driver.find_element_by_xpath('//*[@id="post-22276"]/div/div/p[3]/strong')