forked from Ivan-Kudryavtsev/WWHack2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuoteToFilm.py
41 lines (26 loc) · 949 Bytes
/
QuoteToFilm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import requests
import time
from bs4 import BeautifulSoup
def createLink(input):
split = input.split(" ")
website = "https://www.quodb.com/search/"
for x in split:
website = website + x + "%20"
website = website[:-3]
return website
def QuoteToMovie(quote):
from selenium import webdriver
url = createLink(quote)
webdriver = webdriver.Chrome()
webdriver.get(url)
time.sleep(0.0001)
html = BeautifulSoup(webdriver.page_source, 'html.parser')
webdriver.close()
results = html.find(id="results_table")
times = html.findAll(class_="editable editable-click editable-empty editable-open time")
rows = results.findAll(lambda tag: tag.name == 'tr')
arr = []
for i in range(0, int(len(rows) / 2)):
arr.append([rows[i * 2]['data-title'], times[i].getText()])
return arr
print(QuoteToMovie("The return of the king"))