Python Forum
How can i add multithreading in this example
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can i add multithreading in this example
#1
How can i add multithreading in this example
import xml.etree.ElementTree as et
import requests
from bs4 import BeautifulSoup
import threading


iterar = input ('How many domains you want to check: ')

domainlist = []   
try:
   iterar = int(iterar)
except ValueError:
	print('incorrect value')


if iterar <= 0:
	print('Please write a count of domains you want to be cheked')

i=0

while i<iterar:
	i=i+1
	domainCounter = input(f'Enter Domain N{i}:')
	domainlist.append(domainCounter)


while domainlist:
    domain = domainlist.pop(0)
    result = requests.get(f'http://data.alexa.com/data?cli=20&dat=snbamz&url={domain}', stream = True)
    data_string = result.text
    root = et.fromstring(data_string) 

    rank = [item.attrib.get('RANK') for item in root.findall('.//REACH')]
    print(f"\nDomain: \'{domain}\'")
    print(f"Alexa Rank: {rank}\n".replace("[", "").replace("]", ''))

input()
Reply


Messages In This Thread
How can i add multithreading in this example - by WoodyWoodpecker1 - Aug-10-2020, 04:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  multithreading Hanyx 4 1,353 Jul-29-2022, 07:28 AM
Last Post: Larz60+
Question Problems with variables in multithreading Wombaz 2 1,358 Mar-08-2022, 03:32 PM
Last Post: Wombaz
  Multithreading question amadeok 0 1,797 Oct-17-2020, 12:54 PM
Last Post: amadeok
  matplotlib multithreading catosp 0 2,972 Jul-03-2020, 09:33 AM
Last Post: catosp
  Multithreading dynamically syncronism Rodrigo 0 1,550 Nov-08-2019, 02:33 AM
Last Post: Rodrigo
  Locks in Multithreading Chuonon 0 1,868 Oct-03-2019, 04:16 PM
Last Post: Chuonon
  multithreading issue with output mr_byte31 4 3,240 Sep-11-2019, 12:04 PM
Last Post: stullis
  Multithreading alternative MartinV279 1 2,813 Aug-01-2019, 11:41 PM
Last Post: scidam
  using locks in multithreading in python3 srm 2 3,700 Jul-13-2019, 11:35 AM
Last Post: noisefloor
  Multithreading in a loop valtih 3 16,426 Aug-03-2017, 08:20 PM
Last Post: valtih

Forum Jump:

User Panel Messages

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