Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.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
将c#代码转换为python_C#_Python_Selenium - Fatal编程技术网

将c#代码转换为python

将c#代码转换为python,c#,python,selenium,C#,Python,Selenium,您好,我使用的是selenium scraper,我用C#编写了它,但是我需要将它转换为Python以用于我的应用程序。我很难将元素输出到控制台窗口 C#代码 迄今为止的Python代码 print browser.find_element_by_xpath('/html/body/div/div/div[1]/div[2]/ul/li[2]/ul/li/span[3]/span[3]').text 我收到错误“浏览器上出现意外标记。通过xpath查找元素” 任何帮助都将不胜感激, 谢谢。您需

您好,我使用的是selenium scraper,我用C#编写了它,但是我需要将它转换为Python以用于我的应用程序。我很难将元素输出到控制台窗口

C#代码

迄今为止的Python代码

print browser.find_element_by_xpath('/html/body/div/div/div[1]/div[2]/ul/li[2]/ul/li/span[3]/span[3]').text
我收到错误“浏览器上出现意外标记。通过xpath查找元素” 任何帮助都将不胜感激,
谢谢。

您需要
通过xpath()查找元素(查看
s
):


您需要通过xpath()查找元素(查看
s
):


您可能需要通过xpath将元素编码为utf-8格式

print browser.find_element_by_xpath('/html/body/div/div/div[1]/div[2]/ul/li[2]/ul/li/span[3]/span[3]').text.encode("utf-8")

您可能需要通过xpath将元素编码为utf-8格式

print browser.find_element_by_xpath('/html/body/div/div/div[1]/div[2]/ul/li[2]/ul/li/span[3]/span[3]').text.encode("utf-8")
print browser.find_element_by_xpath('/html/body/div/div/div[1]/div[2]/ul/li[2]/ul/li/span[3]/span[3]').text.encode("utf-8")