Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with threading please!
#1
Hi everyone!

I try to runing multiple-task´s in Python with threading, but not run good... when i execute the script, in one web-page is working, while for the others no work...

The Idea for execute in each web-page, independently and unrelated write:
     - hello1 + enter
     - hello2 + enter
     - holla3 + enter

 number = 3

class ScrapHilo:

    def runningScraper(self,idWeb):
        
        global driver
        global urlWeb 
               
        try:
            for ii in range(1,5):
                
                driver.get(urlWeb)
                
                seleccionar = driver.find_element_by_xpath("//*[@id='lst-ib']")
                seleccionar.send_keys('Hola'+str(ii))
                time.sleep(3)
                
                ActionChains(driver).send_keys(Keys.ENTER ).perform()      
                time.sleep(1.5)
               
        except:   
            print("Problem...")
            

    def __init__(self, number):
        
        for i in range(number):
            hilo = threading.Thread(target=self.abrir_driver,args=(i,), name='hilo_'+str(i))
            hilo.start()                

            
        
    def abrir_driver(self,numhilo):
        
        global uChromeDriver 
        global driver

        driver = webdriver.Chrome(uChromeDriver)
        self.runningScraper(str(numhilo))
        #driver.quit()    

ScrapHilo(number)
Can you tell me how to work with the thread?

Regards
Karlo_ds
Reply
#2
you can download http://greenteapress.com/wp/semaphores/ as a pdf file.
which looks pretty good. Has sections for several languages (including python of course).
Reply
#3
Thank Larz60+
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 1,871 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,131 Oct-01-2021, 08:32 PM
Last Post: muzikman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020