Jan-11-2019, 03:39 PM
your code does work with that site for me. it printed out the html. However you dont need requests or beautifulsoup, if you use selenium. Selenium can make requests and parse html. You can also do it in the background so it doesnt bring up a browser. You should also use wait instead of time sleep. It will be faster.
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC browser = webdriver.Firefox() browser.get("https://torrentz2.eu/") WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'search'))) #class selenium.webdriver.support.expected_conditions.title_contains(Torrent) search = browser.find_element_by_id('thesearchbox') search.send_keys('xxxxx') search.send_keys(Keys.RETURN) # hit return after you enter search text WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'results')))
Recommended Tutorials: