本文整理汇总了Python中splinter.Browser.is_element_present_by_value方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.is_element_present_by_value方法的具体用法?Python Browser.is_element_present_by_value怎么用?Python Browser.is_element_present_by_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类splinter.Browser
的用法示例。
在下文中一共展示了Browser.is_element_present_by_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import is_element_present_by_value [as 别名]
def main(argv):
if len(argv)==0:
help()
report=hvf=hvw=tuits=False
try:
opts, args = getopt.getopt(argv,"hi:u:i:f:w:t:r",["file=","user=","followers=","following=", "tuits=","report="])
except getopt.GetoptError:
help()
for opt, arg in opts:
if opt == '-h':
help()
elif opt in ("-i", "--file"):
txt = arg
elif opt in ("-u", "--user"):
username = arg
elif opt in ("-f", "--followers") and arg=="y":
hvf=True
elif opt in ("-w", "--following") and arg=="y":
hvw=True
elif opt in ("-t", "--tuits") and arg=="y":
tuits=True
elif opt in ("-r", "--report") and arg=="y":
report=True
try:
ufile = open(txt, 'rb').readlines()
except:
print "Cant open %s" % txt
sys.exit(0)
password = raw_input("Enter your twitter password : ")
browser = Browser( 'firefox' , profile_preferences=proxy_settings )
browser.visit("https://twitter.com/login/")
if browser.is_element_present_by_value("Log in", wait_time=8):
aloginb=browser.find_by_xpath('.//button[@type="submit"]')[0]
logintw(browser, aloginb, username, password)
else:
print "timeout loading page"
sys.exit(5)
for line in ufile:
try:
if re.search("intent", line):
url = re.match(r"https?://(www\.)?twitter\.com/intent/(#!/)[email protected]?([^/\s]*)",line.strip())
url = url.group()
urltypeid=True
else:
url = line.strip()
urltypeid=False
browser.visit(url)
time.sleep(1)
if not re.search('suspended', browser.url):
if urltypeid:
browser.find_by_css('a.fn.url.alternate-context').click()
else:
msg = line.strip() + ' - Suspended'
logger(msg)
continue
# report user
msg=" "
if report:
report(browser)
msg="RP"
id = browser.find_by_css('a.ProfileHeaderCard-screennameLink.u-linkComplex.js-nav')["href"][1:]
id = id.split("/")[-1]
followers = browser.find_by_css('a[data-nav="followers"] .ProfileNav-value')
following = browser.find_by_css('a[data-nav="following"] .ProfileNav-value')
try:
msg = "%s %s %s %s" % (followers.value, following.value, url.strip(), msg)
except:
msg = " %s %s " % (url.strip(), msg)
# harvest twitters
if tuits:
if goGetTwitters(id, browser):
msg+=" TW"
# harvest followers
if hvf:
if goharvest(id, browser, "followers"):
msg+=" FO"
# harvest following
if hvw:
#.........这里部分代码省略.........