from bs4 import BeautifulSoup
from selenium import webdriver
url = 'http://www.powerballgame.co.kr/?view=dayLog'
driver = webdriver.PhantomJS('C:\\Users\\user\\Downloads\\phantomjs-2.1.1-
windows\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe')
driver.get(url)
delay_time = 2
driver.implicitly_wait(delay_time)
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
real**strong text**time_round = soup.select('table.powerballBox >
tbody.content > tr > td > span.numberText')
table = soup.find('table',{'class': 'numberText'})
for round in realtime_round:
print(round.text)
#realtime_result = soup.select('table.powerballBox > tbody.content > tr > td
> div.sp-ball_bg')
#for result in realtime_result:
driver.get(url)
data=driver.find_element_by_xpath("//*
[@id='powerballLogBox']/tbody[2]/tr[4]/td[3]/div")
for ii in data:
print(ii.get_attritbute("href"))
“”“ 追溯(最近一次通话): 文件“ C:/Users/user/Desktop/python_project/entry_exampe4.py”,第32行,在 对于数据中的ii: TypeError:“ WebElement”对象不可迭代 “” 当我制作python爬行程序时,确实有此错误代码 我该如何修复代码?
答案 0 :(得分:0)
您需要使用driver.find_elements_by_xpath
而不是driver.find_element_by_xpath
。
请注意,element