I have used python to make a program that can get the name of similar Movies. I have used threading to make sure that the functions run parallel to prevent time wastage.
import threading
import requests
from bs4 import BeautifulSoup
url = "https://www.movie-map.com/twilight.html"
url2 = "https://www.movie-map.com/Interstellar.html"
x = ''
word_list = []
def spider(url):
word_list = []
try:
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, features="lxml")
for link in soup.find('div', attrs = {'id':'gnodMap'}):
title = link.string
word_list.append(title)
except:
pass
x = word_list
return word_list
t1 = threading.Thread(target=spider, args=[url])
t2 = threading.Thread(target=spider, args=[url2])
t1.start()
t2.start()
How should I get the returned value from the functions?