Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中将selenium webelement转换为字符串变量_Python_Selenium - Fatal编程技术网

如何在python中将selenium webelement转换为字符串变量

如何在python中将selenium webelement转换为字符串变量,python,selenium,Python,Selenium,输出是一个列表形式的selenium webelement。我想将其转换为一个字符串变量,以便列表可以包含文本格式的所有作业标题。 如果我能在这方面得到帮助,那就太好了。提前感谢。如果您需要每个作业的链接列表,请: from selenium import webdriver from time import sleep from selenium.common.exceptions import NoSuchAttributeException from selenium.common.exc

输出是一个列表形式的selenium webelement。我想将其转换为一个字符串变量,以便列表可以包含文本格式的所有作业标题。
如果我能在这方面得到帮助,那就太好了。提前感谢。

如果您需要每个作业的链接列表,请:

from selenium import webdriver
from time import sleep
from selenium.common.exceptions import NoSuchAttributeException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get('https://www.linkedin.com/jobs/search?locationId=sg%3A0&f_TP=1%2C2&orig=FCTD&trk=jobs_jserp_posted_one_week')
jobtitlebutton = driver.find_elements_by_class_name('job-title-link')
print(jobtitlebutton)
在这种情况下,如果您只需要职务列表:

job_list = []
jobtitlebuttons = driver.find_elements_by_class_name('job-title-link')
for job in jobtitlebuttons:
    job_list.append(job.get_attribute('href'))

您是否需要链接列表或工作列表(例如“数据中心技术人员”、“测试经理”)?非常感谢,它确实帮了我很多。我还想知道如何单击每个职务标题并提取类名为“content”的职务描述。我想你应该循环查看
job\u列表的链接,并执行类似
description=“/n”。join([I.text for I in driver.find_elements_by_xpath('//div[@class])的操作=“content”]//ul/li')]
非常感谢。这肯定会有帮助
job_list = []
jobtitlebuttons = driver.find_elements_by_class_name('job-title-text')
for job in jobtitlebuttons:
    job_list.append(job.text)