Reputation: 19
I have code that need to go to pages and copy links in loop when I do from page 1 to 14. My question : Why its only show page 14 links its should show page 1-14 links
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
for x in range(1, 14):
driver.get("http://xxxx.com/pages?page=%d" % (x))
text = driver.find_elements_by_xpath("//div[@class='boxALL']/article/a" )
for link in text:
print (link.get_attribute("href"))
driver.implicitly_wait(10)
print (len(text))
Upvotes: 0
Views: 72
Reputation: 9833
You need to indent all of your code to be inside the for x in range(14)
: otherwise it wont run 14 times:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
for x in range(1, 14):
driver.get("http://xxxx.com/pages?page=%d" % (x))
text = driver.find_elements_by_xpath("//div[@class='boxALL']/article/a" )
for link in text:
print (link.get_attribute("href"))
driver.implicitly_wait(10)
print (len(text))
Upvotes: 2