【发布时间】:2016-06-22 05:30:37
【问题描述】:
这在硒中是否可能, 我认为这在 urllib 中是可能的,但我不确定。
if "@gmail.com" in html:
print the string that includes the @gmail
例如:它会找到
@gmail.com,然后它会打印>连接的字符串stackoverflow@gmail.com
【问题讨论】:
标签: python python-2.7 python-3.x selenium
这在硒中是否可能, 我认为这在 urllib 中是可能的,但我不确定。
if "@gmail.com" in html:
print the string that includes the @gmail
例如:它会找到
@gmail.com,然后它会打印>连接的字符串stackoverflow@gmail.com
【问题讨论】:
标签: python python-2.7 python-3.x selenium
是的,这是可能的。您可以使用 page_source 请求页面的整个 HTML。然后你可以检查@gmail.com是否在这个page_source中。
source = driver.page_source
domain = '@gmail.com'
if domain in source:
# Cut off the string behind @gmail.com (the mail is now the last word in the string)
sub = source[:source.find(domain) + len(domain)]
# Get the last space and get the substring that comes after it
mail = sub[sub.rindex(' ') + 1:]
【讨论】:
是的,这是可能的。你想要达到的是:
@gmail.com,你能做的基本上是:
entireDocument = findElement(By.xpath("/html")),此 xpath 将为您提供存储在 entireDocument 变量中的整个 html 文档。 entireDocument 中查找字符串@gmail.com,如果匹配,则提取整个电子邮件地址。【讨论】: