所以我对selenium没有太多的经验,我尝试使用youtube+一些论坛帖子来创建一个剪贴代码,因为我是一名摄影师,我与该领域的其他人一起工作,如果能得到所有摄影师的名单,那就太棒了,让我来展示代码,所以基本上现在,我只对这里的摄影师姓名感兴趣(稍后我需要学习selenium中的分页,但首先我必须通过这个问题):
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import sys
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
bloom ="https://www.photographer.org/?geodir_search=1&stype=gd_place&sgd_placecategory%5B0%5D=8&s=+&snear&sgeo_lat&sgeo_lon"
driver.get(bloom)
eList = driver.find_elements_by_class_name('geodir-entry-title')
hrefList = []
for a in eList:
hrefList.append(a.get_attribute('href'))
for href in hrefList:
print(href)
结果是没有,没有,没有,没有,等等。。。 它应该是“Tsukimi摄影”、“Cherry Logan摄影”等
有什么提示我可能会被卡住吗
谢谢
查看html,我可以看到类为
geodir-entry-title
的元素没有href
属性。因此,None上的输出是预期的。href的预期值类似于“https://www.photographer.org/photographers/tsukimi-photography/"这可以像下面这样做
相关问题 更多 >
编程相关推荐