How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask ATLPROG Your Own Question

ATLPROG
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 7677
Experience:  MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
44910485
Type Your Programming Question Here...
ATLPROG is online now
A new question is answered every 9 seconds

I have 10 URLs in MySQL db which I am going through one by

Customer Question

I have 10 URLs in MySQL db which I am going through one by one and opening each page with Selenium webdriver but I get to the third one in the db and it errors any help be great please. It errors here staff_url = results2[x] I just cant figure it out.
for x in range(0,10):
cursor.execute("SELECT links FROM a.b")
results2 = cursor.fetchone()
time.sleep(5)
while results2 is not None:
staff_url = results2[x]
time.sleep(5)
driver.get(staff_url)
time.sleep(5)
results2 = cursor.fetchone()
time.sleep(5)
submit_button = driver.find_element_by_xpath('//*[@id="aux"]/div[1]/div[2]/ul/li[1]/h4/a')
time.sleep(5)
submit_button.click()
time.sleep(5)
Submitted: 1 year ago.
Category: Programming
Customer: replied 1 year ago.
for x in range(0, 10):
cursor.execute("SELECT links FROM a.b")
results2 = cursor.fetchone()
time.sleep(5)
while results2 is not None:
staff_url = results2[x]
time.sleep(5)
driver.get(staff_url)
time.sleep(5)
results2 = cursor.fetchone()
time.sleep(5)
submit_button = driver.find_element_by_xpath('//*[@id="aux"]/div[1]/div[2]/ul/li[1]/h4/a')
time.sleep(5)
submit_button.click()
time.sleep(5)
Expert:  Freddy M. replied 1 year ago.

Hello my name is***** do not rate until we are finished. I look forward to assisting and am very sorry to hear that you are having this problem. Are you using Python with MySQL?

Customer: replied 1 year ago.
Expert:  Freddy M. replied 1 year ago.

Can you please send me the code for the link before and after this one as well?

Customer: replied 1 year ago.
I only need this part to work it selects the links from the db but errors when it gets to the third one and problem seems to be this part staff_url = results2[x]
Expert:  Freddy M. replied 1 year ago.

In order to help you I need all 3 please. It getting stuck at that command, does not mean that command is the problem. Similar to when troubleshooting a windows boot up it can get stuck showing loading a file, but in reality the next file is the problem. Since you do not however want to send the rest I will opt out and open this to all experts.

Customer: replied 1 year ago.
Ok
Expert:  Steve replied 1 year ago.

Hi, my name is***** things:

1) What's the error?

2) To help you, I would need to look at the links. If it runs the first two without an error, then it's not the syntax of the command, it's a problem with the data, or the link. So I have to be able to look at the data and know what the error message is to help you.

Customer: replied 1 year ago.
Hi as I am testing this I have the same URL for all ten which is google.com and the error i get is tuple index out of range on the staff_url = results2[x] I appreciate you looking at it.
Expert:  Steve replied 1 year ago.

Can you print the value of results2 as the very first statement inside the while loop and tell me what you see?

Expert:  Steve replied 1 year ago.

Hi there, just checking back with you on this. Were you able to print the value of results2 at the beginning of the loop so we can see what's happening?