从Python Selenium中的特定标签获取文本

时间:2019-02-24 17:41:26

标签: python selenium

我想在此处获取此特定元素内的文字

<div class="comment-text-inner display-inline" data-clipboard-text="free apex coins">free apex coins</div>

如何使用python和selenium从“数据剪贴板文本”中获取文本?

我尝试过

comment = driver.find_element_by_xpath("""/html/body/div[3]/div/div[2]/div[2]/div/div/div/div[4]/div[2]/div/div[1]""").text

没有运气

1 个答案:

答案 0 :(得分:2)

我认为您正在寻找方法location / { try_files $uri $uri/ /index.php?$args; } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~* ^.+\.(eot|otf|woff|woff2|ttf|rss|atom|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ { expires 1M; access_log off; add_header Cache-Control "public"; } location ~* \.(?:css|js)$ { expires 1y; access_log off; add_header Cache-Control "public"; } location ~* \.(html)$ { expires 7d; access_log off; add_header Cache-Control "public"; } location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ { expires 7d; add_header Cache-Control "public, no-transform"; } gzip on; gzip_disable "msie6"; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default) include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "upload_max_filesize=4096m post_max_size=4096m"; fastcgi_pass cake-web_wp:9000; }

从本质上讲,它将类似于:

get_attribute()

也请参见this post