我有这段代码。
if scroll:
for x in range(0,scroll):
print ("Rescrolling username=>",self.username)
time.sleep(3)
self.driver.execute_script(self.SCROLLSCRIPT)
time.sleep(3)
posts = self.driver.find_elements_by_css_selector("article.feed-item")
print(str(len(posts)) + " posts found.")
targets = []
for post in posts:
targets.append(post.find_element_by_class_name("new-profile-icon").get_attribute("title"))
print "Total targets found => ", len(targets)
return targets
由于某种原因,我在第21行出现错误。
print "Total targets found => ", len(targets)
^
SyntaxError: invalid syntax
我不知道为什么会这样。